5.5. ClassLoader API Reference

seasar\util\ClassLoader class searches the class file on a file system, and loads a class definition through an autoload function. Import of a class is performed by the following method.

seasar\util\ClassLoader::import($path, $namespace = array(), $strict = false, $pear = false, $recursive = true)
  • 1st argument : path to direcotry searched
  • 2nd argument : string or array of namespace
  • 3rd argument : In the case of true, The name space specified by $namespace is used. In the case of false, The searched subdirectory name is added to $namespace array one by one.
  • 4th argument : In the case of true, $namespace is imploded by "_" (underscore). In the case of false, $namespace is imploded by "\"
  • 5th argument : In the case of true, a directory is searched recursively. In the case of false, a subdirectory is not searched.

The class file (.php, .class.php) in the directory specified by the 1st argument are imported. The path of a class file and a class name are read in import method call. This information is used when a class definition is required in autoload function. A class name becomes a portion except the extension of a class file name. As an example, when a class file name is "S2Container.php" or "S2Container.class.php", "S2Container" becomes a class name.

If specifying namespace by a character string by the 2nd argument, it specifies like "example.logic." When specifying in array, it becomes like "array('example', 'logic')".

© Copyright The Seasar Foundation and the others 2005-2010, all rights reserved.