PHP
  Home arrow PHP arrow Using Static Methods to Build Loader Apps in PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Using Static Methods to Build Loader Apps in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2009-06-03


    Table of Contents:
  • Using Static Methods to Build Loader Apps in PHP
  • Review: a basic file loading system with PHP 5
  • A static file loading method
  • Loading files using a static class method

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using Static Methods to Build Loader Apps in PHP
    ( Page 1 of 4 )

    If you’re a PHP developer who has already worked with popular third-party frameworks like Kohana and CodeIgniter, or even better, have created one all by yourself, then you're familiar with building file loading applications. The process can be tackled pretty easily, either by using a procedural approach or the object-oriented paradigm. In this eight-part series, we take a close look at building file-loading applications. This second part of the series will focus on static methods.

    As its name suggests, a file loading program (or a resource loading program, to express the concept more accurately), is simply a PHP module that takes care of including, usually via its set of “include()/require() native functions, files that are required by an application to make it work as expected.

    In many cases, loading files within a program can be seen simply as a one-to-one relationship, where one “include()/include_once() or “require()/require_once()” function is used explicitly with each required file. Although this method can be quite effective when developing small-scale applications, it can lead to many maintenance headaches when building larger ones.

    Fortunately, it’s possible to create more sophisticated and elegant file loaders with minor hassles, by combining classic PHP includes along with the magic “__autoload()” function and some of the functions and classes supplied by the Standard PHP Library (SPL) available in PHP 5.

    The goal of this series of articles is to demonstrate, in a step-by-step fashion, how to build several file loading programs. These range from using a “require_once()” function per requested file, to developing loader classes capable of including a specified file by using a recursive search through the file system on a web server.

    Actually, I’m getting ahead of myself, since it’s time to summarize the topics that were covered in the first part of this series. In that article, I explained how to create a rudimentary file loader class, which via a dynamic “load()” method, had the ability to include a specific file into a given application.

    It’s worthwhile to mention, however, that it was necessary to create an instance of the aforementioned class to load a determined file. This is a process that can be completely avoided in terms of good coding habits. But how can this be achieved? Well, it’s feasible to statically call the class’s load()” method,  preventing its unwanted instantiation.

    So, in the next few lines I’m going to illustrate how to do that, by way of a decent variety of code samples that you’ll grasp very quickly.

    Are you ready to tackle this second installment of the series? Then let’s move forward now!



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

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek