HomePHP Including Files Recursively with Loader Applications in PHP
Including Files Recursively with Loader Applications in PHP
Welcome to the fourth chapter of the series that shows you how to build loader applications with PHP. Made up of seven parts, this series uses a variety of code samples to teach you how to create modular programs. These programs are capable of recursively including files required by a given application, without having to explicitly call any “include()/include_once()” or “require()/require_once()” PHP function.
And now that you’ve been introduced to the main goal of this series, it’s time to summarize the topics that were discussed in the last tutorial. In the previous part I went through the development of a file loading class in PHP 5. This class was capable of searching recursively for a determined file on the web server, based on a starting path passed to its “load()” main method.
Having a class like this makes it much easier to dynamically load resources and dependencies that may be located in different folders on the server. Its recursive “load()” method does the hard work and takes care of the whole loading process, independently of the location of a required file.
Nonetheless, the best way to understand how this loader class works and how functional it can be in concrete situations is by setting up several examples that show it in action.
Bearing in mind this idea, in this fourth installment of the series I’m going to provide you with a number of code samples that will demonstrate the actual benefits of using the “Loader” class created in the preceding tutorial.
Now, let’s leave the boring theory behind us and see the real functionality of this recursive file loader program. Let’s jump in!