Zend Framework  1.12
Static Public Member Functions | Static Protected Member Functions | List of all members
Zend_Loader Class Reference

Static Public Member Functions

static loadClass ($class, $dirs=null)
 Loads a class from a PHP file.
 
static loadFile ($filename, $dirs=null, $once=false)
 Loads a PHP file.
 
static isReadable ($filename)
 Returns TRUE if the $filename is readable, or FALSE otherwise.
 
static explodeIncludePath ($path=null)
 Explode an include path into an array.
 
static autoload ($class)
 spl_autoload() suitable implementation for supporting class autoloading.
 
static registerAutoload ($class= 'Zend_Loader', $enabled=true)
 Register autoload() with spl_autoload()
 
static standardiseFile ($file)
 Standardise the filename.
 

Static Protected Member Functions

static _securityCheck ($filename)
 Ensure that filename does not contain exploits.
 
static _includeFile ($filespec, $once=false)
 Attempt to include() the file.
 

Member Function Documentation

static _includeFile (   $filespec,
  $once = false 
)
staticprotected

Attempt to include() the file.

include() is not prefixed with the @ operator because if the file is loaded and contains a parse error, execution will halt silently and this is difficult to debug.

Always set display_errors = Off on production servers!

Parameters
string$filespec
boolean$once
Returns
boolean
Deprecated:
Since 1.5.0; use loadFile() instead
static _securityCheck (   $filename)
staticprotected

Ensure that filename does not contain exploits.

Parameters
string$filename
Returns
void
Exceptions
Zend_Exception

Security check

static autoload (   $class)
static

spl_autoload() suitable implementation for supporting class autoloading.

Attach to spl_autoload() using the following: spl_autoload_register(array('Zend_Loader', 'autoload'));

Deprecated:
Since 1.8.0
Parameters
string$class
Returns
string|false Class name on success; false on failure
static explodeIncludePath (   $path = null)
static

Explode an include path into an array.

If no path provided, uses current include_path. Works around issues that occur when the path includes stream schemas.

Parameters
string | null$path
Returns
array
static isReadable (   $filename)
static

Returns TRUE if the $filename is readable, or FALSE otherwise.

This function uses the PHP include_path, where PHP's is_readable() does not.

Note from ZF-2900: If you use custom error handler, please check whether return value from error_reporting() is zero or not. At mark of fopen() can not suppress warning if the handler is used.

Parameters
string$filename
Returns
boolean
static loadClass (   $class,
  $dirs = null 
)
static

Loads a class from a PHP file.

The filename must be formatted as "$class.php".

If $dirs is a string or an array, it will search the directories in the order supplied, and attempt to load the first matching file.

If $dirs is null, it will split the class name at underscores to generate a path hierarchy (e.g., "Zend_Example_Class" will map to "Zend/Example/Class.php").

If the file was not found in the $dirs, or if no $dirs were specified, it will attempt to load it from PHP's include_path.

Parameters
string$class- The full class name of a Zend component.
string | array$dirs- OPTIONAL Either a path or an array of paths to search.
Returns
void
Exceptions
Zend_Exception
static loadFile (   $filename,
  $dirs = null,
  $once = false 
)
static

Loads a PHP file.

This is a wrapper for PHP's include() function.

$filename must be the complete filename, including any extension such as ".php". Note that a security check is performed that does not permit extended characters in the filename. This method is intended for loading Zend Framework files.

If $dirs is a string or an array, it will search the directories in the order supplied, and attempt to load the first matching file.

If the file was not found in the $dirs, or if no $dirs were specified, it will attempt to load it from PHP's include_path.

If $once is TRUE, it will use include_once() instead of include().

Parameters
string$filename
string | array$dirs- OPTIONAL either a path or array of paths to search.
boolean$once
Returns
boolean
Exceptions
Zend_Exception

Search in provided directories, as well as include_path

Try finding for the plain filename in the include_path.

If searching in directories, reset include_path

static registerAutoload (   $class = 'Zend_Loader',
  $enabled = true 
)
static

Register autoload() with spl_autoload()

Deprecated:
Since 1.8.0
Parameters
string$class(optional)
boolean$enabled(optional)
Returns
void
Exceptions
Zend_Exceptionif spl_autoload() is not found or if the specified class does not have an autoload() method.
static standardiseFile (   $file)
static

Standardise the filename.

Convert the supplied filename into the namespace-aware standard, based on the Framework Interop Group reference implementation: http://groups.google.com/group/php-standards/web/psr-0-final-proposal

The filename must be formatted as "$file.php".

Parameters
string$file- The file name to be loaded.
Returns
string