Example #4. use external classes and PHP files in Laravel Controller You can do this either using the include() function or the require() function. If the file is not found, a warning is shown and the program continues to run. The ability to refer to an external fully qualified name with an alias, or importing, is an important feature of namespaces. It can be done by using @import keyword. Files External JavaScript file named as “main.js”. PHP Include from Root Of course, we can wrap them in a class as well, but not always. It copies the included file code in the added location of the file which is same as writing the scripting code in the location. In the examples above, we used the include function. The functions.php file is used to add, remove, or otherwise change the default behaviors of WordPress. Include Functions