PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend Framework 101: Zend_Loader

This article is part of the series “Zend Framework 101”. The Zend Framework 101 series covers many components that make up the Zend Framework in easy to understand articles.. Read more about Zend Framework 101...

Introduction

In this article I will introduce you to Zend_Loader, a Zend Framework class used to automatically load other classes. Typically you would use include_once() or require_once() when you want to load a class but using Zend_Loader you don't have to.

For class auto-loading to work (see http://php.net/autoload for full details), your classes must be named and filed in an orderly fashion. The Zend_Loader class requires all classes to be named in the same fashion as classes in the Zend Framework.

Zend_Loader treats a class name as a file system path, replacing any underscores with a slash and appending .php to the end. For example, the class name Zend_Loader would map to the file system path Zend/Loader.php.

Note: This is relative to your PHP include path, which can be defined with the include_path configuration directive.

This article requires PHP 5.2 or newer and Zend Framework. You can download the Zend Framework from http://framework.zend.com. At time of writing, the current version of Zend Framework is 1.7.6.

In This Article