autoloader
[ class tree: autoloader ] [ index: autoloader ] [ all elements ]

Procedural File: Autoloader.php

Source Location: /Autoloader.php



Page Details:

The Autoloader works out of the box as simple as possible. You have nothing more to do than require this file. Don't bother the time it consumes when it's called the first time. Let it build its index.

The second time it will run as fast as light.

The simplest and probably most common usecase shows this example:

index.php

  1.  <?php
  2.  require dirname(__FILE__"/autoloader/Autoloader.php";
  3.  $myObject new MyClass();

classes/MyClass.php

  1.  <?php
  2.  class MyClass extends MyParentClass }

classes/MyParentClass.php

  1.  <?php
  2.  class MyParentClass }

As you can see it's only necessary to require this file once. If this is done in the document root of your classes (index.php in this case) the Autoloader is already configured. After requiring this file you don't have to worry where your classes reside.

If you have the possibility to enable PHP's tokenizer you should do this. Otherwise the Autoloader has to use a Parser based on PCRE which is not as reliable as PHP's tokenizer.

The Autoloader assumes that a class name is unique. If you have classes with equal names the behaviour is undefined.




Tags:

author:  Markus Malkusch <markus@malkusch.de>
version:  1.0
copyright:  Copyright (C) 2010 Markus Malkusch
see:  Autoloader


Includes:

require_once(dirname(__FILE__)."/classes/Autoloader.php") [line 67]






Documentation generated on Fri, 27 Nov 2009 11:36:26 +0100 by phpDocumentor 1.4.3