|
Size: | 11488 |
Storage flags: | no_autoload,compress/gzip (34%) |
To understand autoloading in Zend Framework, first you need to understand the relationship between class names and class files.
Zend Framework has borrowed an idea from PEAR, whereby class names have a 1:1 relationship with the filesystem. Simply put, the underscore character (“_”) is replaced by a directory separator in order to resolve the path to the file, and then the suffix “.php” is added. For example, the class “Foo_Bar_Baz” would correspond to “Foo/Bar/Baz.php” on the filesystem. The assumption is also that the classes may be resolved via PHP‘s include_path setting, which allows both include() and require() to find the filename via a relative path lookup on the include_path.
Additionally, per PEAR as well as the PHP project, we use and recommend using a vendor or project prefix for your code. What this means is that all classes you write will share a common class prefix; for example, all code in Zend Framework has the prefix “Zend_”. This naming convention helps prevent naming collisions. Within Zend Framework, we often refer to this as the “namespace” prefix; be careful not to confuse it with PHP‘s native namespace implementation.
Zend Framework follows these simple rules internally, and our coding standards encourage that you do so as well for all library code.
Zend Framework’s autoloading support, provided primarily via Zend\Loader\Autoloader, has the following goals and design elements:
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.