Home arrow PHP arrow Working Out of the Object Context to Build Loader Apps in PHP

Working Out of the Object Context to Build Loader Apps in PHP

Welcome to the fifth part of an eight-part article series that teaches you how to build loader applications with PHP. In this installment of the series, I explain how to create a small, efficient file loader class, with a difference: no instance of it needs to be spawned to include a targeted file, thanks to the implementation of a static recursive loading method.

TABLE OF CONTENTS:
  1. Working Out of the Object Context to Build Loader Apps in PHP
  2. Review: recursive file loading program
  3. Improving the definition of the Loader class
  4. The Loader class in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
June 25, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Building small programs with PHP that can load a specified file or resource is an easily-tackled process for many developers with only average experience in the language. However, things can get more complex when trying to add some useful characteristics to these programs, such as recursive file search capabilities and exception handling. This requires a more intimate knowledge of the object paradigm and mastering some features that are only present in PHP 5.

Not all is lost, though, if you're trying to build this kind of file loading application, since this group of articles will guide you through the entire development process in a truly friendly way, using a strong hands-on approach. 

Of course, if you've been a patient reader who already went through all of the preceding articles of this series, then you probably have a solid background in how to create some handy file loading programs with PHP 5. In the aforementioned tutorials I discussed their construction, and once the basic concepts  were properly covered, I proceeded to implement a few useful features, such as the capacity for including a specified file by means of recursive searches, using a starting file path. 

The file loader class developed in the last chapter had a "load()" method that implemented this recursive ability in a truly straightforward fashion. Nevertheless, it's valid to stress here that it's necessary to create an instance of this class to include a determined file, except in those cases where its loading method is called statically. 

However, to avoid an eventual (and unnecessary) instantiation of the loader class, it would be helpful to declare the mentioned "load()" method static. Thus, bearing in mind this important concept, in this fifth part of the series I'm going to enhance the signature of the "Loader" class created previously by turning its loading method into a static one. 

Want to learn the full details of how this will be accomplished in a few simple steps? Then don't waste more time; start reading now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: