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

Class: Autoloader

Source Location: /classes/Autoloader.php

Class Overview


An implemtation for Autoloading classes in PHP.


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright (C) 2010 Markus Malkusch

Constants

Methods



Class Details

[line 109]
An implemtation for Autoloading classes in PHP.

This Autoloader implementation searches recursivly in defined class paths for a class definition.

Additionally it provides PHP with the class constructor __static(). If a class has a public and static method __static() the Autoloader will call this method.

Actually there's no need to define a class path with Autoloader->addPath() as the constructor uses the path of the debug_backtrace().




Tags:

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


[ Top ]


Class Methods


static method getDefaultInstance [line 171]

static Autoloader getDefaultInstance( )



Tags:

return:  the default Autoloader
access:  public


[ Top ]

static method getRegisteredAutoloaders [line 244]

static Array getRegisteredAutoloaders( )



Tags:

return:  all registered Autoloader instances which are doing their jobs
see:  Autoloader::register()
access:  public


[ Top ]

static method registerInternalClass [line 184]

static void registerInternalClass( String $class, String $path)

This is used for internal classes, which cannot use the Autoloader. They will be required in a traditional way without any index or searching.



Tags:

access:  public


Parameters:

String   $class  
String   $path  

[ Top ]

static method removeAll [line 232]

static void removeAll( )

All instances of Autoloader will be removed from the stack.



Tags:

see:  Autoloader::remove()
access:  public


[ Top ]

static method __static [line 163]

static void __static( )

A default Autoloader will be created.



Tags:

access:  public


[ Top ]

method addCallersPath [line 377]

void addCallersPath( )

Adds the class path of the caller. This will be done automatically if no class path is set.



Tags:

see:  Autoloader::addPath()
see:  Autoloader::removeGuessedPath()
see:  Autoloader::register()
throws:  AutoloaderException_GuessPathFailed
access:  public


[ Top ]

method addPath [line 339]

void addPath( String $path)

You can define several class paths in which the Autoloader will search for classes.



Tags:

see:  Autoloader::removePath()
access:  public


Parameters:

String   $path   A class path

[ Top ]

method addSkipPattern [line 423]

void addSkipPattern( String $pattern)

Adds a regular expression for ignoring files in the class paths.

Files which paths match one of these patterns won't be searched for class definitions.

This is useful for version control paths where files with class definitions exists. Subversion (.svn) and CVS (.CVS) are excluded by default.




Tags:

see:  $skipPatterns
access:  public


Parameters:

String   $pattern   a regular expression including delimiters

[ Top ]

method autoload [line 461]

void autoload( String $class)

PHP will call this method for loading a class.

If this Autoloader doesn't find a class defintion it will only raise an error if it is the last Autoloader in the stack.




Tags:

see:  handleErrors()
access:  public


Parameters:

String   $class  

[ Top ]

method getParser [line 212]

AutoloaderFileParser getParser( )



Tags:

access:  public


[ Top ]

method getPaths [line 447]

Array getPaths( )



Tags:

return:  The class paths
access:  public


[ Top ]

method register [line 284]

void register( )

This Autoloader will be registered at the stack.

After registration this Autoloader is autoloading class definitions.

There is no need to configure this object. All missing members are initialized before registration: -The index would be an AutoloaderIndex_SerializedHashtable_GZ -The parser will be (if PHP has tokenizer support) an AutoloaderFileParser_Tokenizer -The class path is set to the directory of the calling file

http://www.php.net/spl_autoload_register disables __autoload(). This might be unwanted, so register() also adds __autoload() to the stack.




Tags:

see:  Autoloader::addCallersPath()
see:  spl_autoload_register()
see:  AutoloaderFileParser_Tokenizer
see:  Autoloader::setParser()
see:  Autoloader::setIndex()
see:  AutoloaderIndex_SerializedHashtable_GZ
throws:  AutoloaderException_GuessPathFailed
access:  public


[ Top ]

method remove [line 222]

void remove( )

This Autoloader will be removed from the stack.



Tags:

see:  Autoloader::removeAll()
access:  public


[ Top ]

method removeAllPaths [line 363]

void removeAllPaths( )

remove all class paths.



Tags:

see:  Autoloader::removePath()
access:  public


[ Top ]

method removeGuessedPath [line 405]

void removeGuessedPath( )

register() automatically adds a guessed path where it assumes to find classes. If you're not happy with this path, you might remove it from the class path list.



Tags:



[ Top ]

method removePath [line 352]

void removePath( String $path)

remove a class path



Tags:

see:  Autoloader::addPath()
see:  Autoloader::removeAllPaths()
access:  public


Parameters:

String   $path   A class path

[ Top ]

method setIndex [line 326]

void setIndex( AutoloaderIndex $index)

You might change the index if your not happy with the default index AutoloaderIndex_SerializedHashtable_GZ.



Tags:

see:  AutoloaderIndex_SerializedHashtable_GZ
access:  public


Parameters:

AutoloaderIndex   $index  

[ Top ]

method setParser [line 204]

void setParser( AutoloaderFileParser $parser)

Sets a AutoloaderFileParser.

This is not necessary to call, as the Autoloader initializes itself with the best available parser.




Tags:

access:  public


Parameters:

AutoloaderFileParser   $parser  

[ Top ]

method setSkipFilesize [line 439]

void setSkipFilesize( int $size)

Set a file size to ignore files bigger than $size.

The autoloader has to look into every file. Large files like images may result in exceeding the max_execution_time.

Default is set to 1MB. A size of 0 would disable this limitation.




Tags:

see:  $skipFilesize
access:  public


Parameters:

int   $size   Size in bytes

[ Top ]


Class Constants

CLASS_CONSTRUCTOR =  '__static'

[line 115]

The name of the class constructor is __static.


[ Top ]



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