Zend_Loader-Autoloader.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.loader.autoloader">
  4. <title>The Autoloader</title>
  5. <para>
  6. <classname>Zend_Loader_Autoloader</classname> introduces a comprehensive
  7. autoloading solution for Zend Framework. It has been designed with
  8. several goals in mind:
  9. </para>
  10. <itemizedlist>
  11. <listitem>
  12. <para>
  13. Provide a true namespace autoloader. (Previous incarnations
  14. intercepted all userland namespaces.)
  15. </para>
  16. </listitem>
  17. <listitem>
  18. <para>
  19. Allow registering arbitrary callbacks as autoloaders, and manage
  20. them as a stack. (At the time of this writing, this overcomes some
  21. issues with <code>spl_autoload</code>, which does not allow
  22. re-registering a callback that utilizes an instance method.)
  23. </para>
  24. </listitem>
  25. <listitem>
  26. <para>
  27. Allow optimistic matching of namespaces to provide faster class resolution.
  28. </para>
  29. </listitem>
  30. </itemizedlist>
  31. <para>
  32. <classname>Zend_Loader_Autoloader</classname> implements a singleton, making it
  33. unversally accessible. This provides the ability to register additional
  34. autoloaders from anywhere in your code as necessary.
  35. </para>
  36. <sect2 id="zend.loader.autoloader.usage">
  37. <title>Using the Autoloader</title>
  38. <para>
  39. The first time an instance of the autoloader is retrieved, it
  40. registers itself with <code>spl_autoload</code>. You retrieve an
  41. instance using the <methodname>getInstance()</methodname> method:
  42. </para>
  43. <programlisting language="php"><![CDATA[
  44. $autoloader = Zend_Loader_Autoloader::getInstance();
  45. ]]></programlisting>
  46. <para>
  47. By default, the autoloader is configured to match the "Zend_" and
  48. "ZendX_" namespaces. If you have your own library code that uses
  49. your own namespace, you may register it with the autoloader using
  50. the <methodname>registerNamespace()</methodname> method. For instance, if your
  51. library code is prefixed with "My_", you could do so as follows:
  52. </para>
  53. <programlisting language="php"><![CDATA[
  54. $autoloader->registerNamespace('My_');
  55. ]]></programlisting>
  56. <note>
  57. <title>Namespace Prefixes</title>
  58. <para>
  59. You'll note that the previous example uses "My_" and not "My".
  60. This is because <classname>Zend_Loader_Autoloader</classname> is intended
  61. as a general purpose autoloader, and does not make the
  62. assumption that a given class prefix namespace includes an
  63. underscore. If your class namespace <emphasis>does</emphasis>
  64. include one, you should include it when registering your
  65. namespace.
  66. </para>
  67. </note>
  68. <para>
  69. You can also register arbitrary autoloader callbacks, optionally
  70. with a specific namespace (or group of namespaces).
  71. <classname>Zend_Loader_Autoloader</classname> will attempt to match these
  72. first before using its internal autoloading mechanism.
  73. </para>
  74. <para>
  75. As an example, you may want to utilize one or more eZcomponents
  76. components with your Zend Framework application. To use its
  77. autoloading capabilities, push it onto the autoloader stack using
  78. <methodname>pushAutoloader()</methodname>:
  79. </para>
  80. <programlisting language="php"><![CDATA[
  81. $autoloader->pushAutoloader(array('ezcBase', 'autoload'), 'ezc');
  82. ]]></programlisting>
  83. <para>
  84. This tells the autoloader to use the eZcomponents autoloader for
  85. classes beginning with "ezc".
  86. </para>
  87. <para>
  88. You can use the <methodname>unshiftAutoloader()</methodname> method to add the
  89. autoloader to the beginning of the autoloader chain.
  90. </para>
  91. <para>
  92. By default, <classname>Zend_Loader_Autoloader</classname> does no error
  93. suppression when using its internal autoloader, which utilizes
  94. <methodname>Zend_Loader::loadClass()</methodname>. Most of the time, this is
  95. exactly what you want. However, there may be cases where you want to
  96. suppress them. You can do this using
  97. <methodname>suppressNotFoundWarnings()</methodname>:
  98. </para>
  99. <programlisting language="php"><![CDATA[
  100. $autoloader->suppressNotFoundWarnings(true);
  101. ]]></programlisting>
  102. <para>
  103. Finally, there may be times when you want the autoloader to load any
  104. namespace. For instance, PEAR libraries do not share a common
  105. namespace, making specifying individual namespaces difficult when
  106. many PEAR components are in use. You can use the
  107. <methodname>setFallbackAutoloader()</methodname> method to have the autoloader
  108. act as a catch-all:
  109. </para>
  110. <programlisting language="php"><![CDATA[
  111. $autoloader->setFallbackAutoloader(true);
  112. ]]></programlisting>
  113. <note>
  114. <title>Loading Classes from PHP Namespaces</title>
  115. <para>
  116. Starting in version 1.10.0, Zend Framework now allows loading classes from
  117. <acronym>PHP</acronym> namespaces. This support follows the same guidelines and
  118. implementation as that found in the <ulink
  119. url="http://groups.google.com/group/php-standards/web/psr-0-final-proposal">PHP
  120. Framework Interop Group PSR-0</ulink> reference implementation.
  121. </para>
  122. <para>
  123. Under this guideline, the following rules apply:
  124. </para>
  125. <itemizedlist>
  126. <listitem>
  127. <para>
  128. Each namespace separator is converted to a
  129. <constant>DIRECTORY_SEPARATOR</constant> when loading from the file system.
  130. </para>
  131. </listitem>
  132. <listitem>
  133. <para>
  134. Each "_" character in the <emphasis>CLASS NAME</emphasis> is converted to a
  135. <constant>DIRECTORY_SEPARATOR</constant>. The "_" character has no special
  136. meaning in the namespace.
  137. </para>
  138. </listitem>
  139. <listitem>
  140. <para>
  141. The fully-qualified namespace and class is suffixed with ".php" when loading
  142. from the file system.
  143. </para>
  144. </listitem>
  145. </itemizedlist>
  146. <para>
  147. As examples:
  148. </para>
  149. <itemizedlist>
  150. <listitem>
  151. <para>
  152. <classname>\Doctrine\Common\IsolatedClassLoader</classname> =&gt;
  153. <filename>/path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php</filename>
  154. </para>
  155. </listitem>
  156. <listitem>
  157. <para>
  158. <classname>\namespace\package\Class_Name</classname> =&gt;
  159. <filename>/path/to/project/lib/vendor/namespace/package/Class/Name.php</filename>
  160. </para>
  161. </listitem>
  162. <listitem>
  163. <para>
  164. <classname>\namespace\package_name\Class_Name</classname> =&gt;
  165. <filename>/path/to/project/lib/vendor/namespace/package_name/Class/Name.php</filename>
  166. </para>
  167. </listitem>
  168. </itemizedlist>
  169. </note>
  170. </sect2>
  171. <sect2 id="zend.loader.autoloader.zf-version">
  172. <title>Selecting a Zend Framework version</title>
  173. <para>
  174. Typically, you will use the version of Zend Framework that the autoloader you
  175. instantiate came with. However, when developing a project, it's often useful to track
  176. specific versions, major or minor branches, or just the latest version.
  177. <classname>Zend_Loader_Autoloader</classname>, as of version 1.10, offers some features
  178. to help manage this task.
  179. </para>
  180. <para>
  181. Imagine the following scenario:
  182. </para>
  183. <itemizedlist>
  184. <listitem>
  185. <para>
  186. During <emphasis>development</emphasis>, you want to track the latest version of
  187. Zend Framework you have installed, so that you can ensure the application works
  188. when you upgrade between versions.
  189. </para>
  190. <para>
  191. When pushing to <emphasis>Quality Assurance</emphasis>, however, you need to
  192. have slightly more stability, so you want to use the latest installed revision
  193. of a specific minor version.
  194. </para>
  195. <para>
  196. Finally, when you push to <emphasis>production</emphasis>, you want to pin to a
  197. specific installed version, to ensure no breakage occurs if or when you add new
  198. versions of Zend Framework to you server.
  199. </para>
  200. </listitem>
  201. </itemizedlist>
  202. <para>
  203. The autoloader allows you to do this with the method
  204. <methodname>setZfPath()</methodname>. This method takes two arguments, a
  205. <emphasis>path</emphasis> to a set of Zend Framework installations, and a
  206. <emphasis>version</emphasis> to use. Once invoked, it prepends a path to the
  207. <constant>include_path</constant> pointing to the appropriate Zend Framework
  208. installation library.
  209. </para>
  210. <para>
  211. The directory you specify as your <emphasis>path</emphasis> should have a tree such as
  212. the following:
  213. </para>
  214. <programlisting language="text"><![CDATA[
  215. ZendFramework/
  216. |-- 1.9.2/
  217. | |-- library/
  218. |-- ZendFramework-1.9.1-minimal/
  219. | |-- library/
  220. |-- 1.8.4PL1/
  221. | |-- library/
  222. |-- 1.8.4/
  223. | |-- library/
  224. |-- ZendFramework-1.8.3/
  225. | |-- library/
  226. |-- 1.7.8/
  227. | |-- library/
  228. |-- 1.7.7/
  229. | |-- library/
  230. |-- 1.7.6/
  231. | |-- library/
  232. ]]></programlisting>
  233. <para>
  234. (where <emphasis>path</emphasis> points to the directory "ZendFramework" in the above
  235. example)
  236. </para>
  237. <para>
  238. Note that each subdirectory should contain the directory <filename>library</filename>,
  239. which contains the actual Zend Framework library code. The individual subdirectory names
  240. may be version numbers, or simply be the untarred contents of a standard Zend Framework
  241. distribution tarball/zipfile.
  242. </para>
  243. <para>
  244. Now, let's address the use cases. In the first use case, in
  245. <emphasis>development</emphasis>, we want to track the latest source install. We can do
  246. that by passing "latest" as the version:
  247. </para>
  248. <programlisting language="php"><![CDATA[
  249. $autoloader->setZfPath($path, 'latest');
  250. ]]></programlisting>
  251. <para>
  252. In the example from above, this will map to the directory
  253. <filename>ZendFramework/1.9.2/library/</filename>; you can verify this by checking the
  254. return value of <methodname>getZfPath()</methodname>.
  255. </para>
  256. <para>
  257. In the second situation, for <emphasis>quality assurance</emphasis>, let's say we want
  258. to pin to the 1.8 minor release, using the latest install you have for that release. You
  259. can do so as follows:
  260. </para>
  261. <programlisting language="php"><![CDATA[
  262. $autoloader->setZfPath($path, '1.8');
  263. ]]></programlisting>
  264. <para>
  265. In this case, it will find the directory
  266. <filename>ZendFramework/1.8.4PL1/library/</filename>.
  267. </para>
  268. <para>
  269. In the final case, for <emphasis>production</emphasis>, we'll pin to a specific version
  270. -- 1.7.7, since that was what was available when Quality Assurance tested prior to our
  271. release.
  272. </para>
  273. <programlisting language="php"><![CDATA[
  274. $autoloader->setZfPath($path, '1.7.7');
  275. ]]></programlisting>
  276. <para>
  277. Predictably, it finds the directory <filename>ZendFramework/1.7.7/library/</filename>.
  278. </para>
  279. <para>
  280. You can also specify these values in the configuration file you use with
  281. <filename>Zend_Application</filename>. To do so, you'd specify the following
  282. information:
  283. </para>
  284. <programlisting language="ini"><![CDATA[
  285. [production]
  286. autoloaderZfPath = "path/to/ZendFramework"
  287. autoloaderZfVersion = "1.7.7"
  288. [qa]
  289. autoloaderZfVersion = "1.8"
  290. [development]
  291. autoloaderZfVersion = "latest"
  292. ]]></programlisting>
  293. <para>
  294. Note the different environment sections, and the different version specified in each
  295. environment; these factors will allow <classname>Zend_Application</classname> to
  296. configure the autoloader appropriately.
  297. </para>
  298. <warning>
  299. <title>Performance implications</title>
  300. <para>
  301. For best performance, either do not use this feature, or specify a specific Zend
  302. Framework version (i.e., not "latest", a major revision such as "1", or a minor
  303. revision such as "1.8"). Otherwise, the autoloader will need to scan the provided
  304. path for directories matching the criteria -- a somewhat expensive operation to
  305. perform on each request.
  306. </para>
  307. </warning>
  308. </sect2>
  309. <sect2 id="zend.loader.autoloader.interface">
  310. <title>The Autoloader Interface</title>
  311. <para>
  312. Besides being able to specify arbitrary callbacks as autoloaders,
  313. Zend Framework also defines an interface autoloading classes may
  314. imlement, <classname>Zend_Loader_Autoloader_Interface</classname>:
  315. </para>
  316. <programlisting language="php"><![CDATA[
  317. interface Zend_Loader_Autoloader_Interface
  318. {
  319. public function autoload($class);
  320. }
  321. ]]></programlisting>
  322. <para>
  323. When using this interface, you can simply pass a class instance to
  324. <classname>Zend_Loader_Autoloader</classname>'s
  325. <methodname>pushAutoloader()</methodname>
  326. and <methodname>unshiftAutoloader()</methodname> methods:
  327. </para>
  328. <programlisting language="php"><![CDATA[
  329. // Assume Foo_Autoloader implements Zend_Loader_Autoloader_Interface:
  330. $foo = new Foo_Autoloader();
  331. $autoloader->pushAutoloader($foo, 'Foo_');
  332. ]]></programlisting>
  333. </sect2>
  334. <sect2 id="zend.loader.autoloader.reference">
  335. <title>Autoloader Reference</title>
  336. <para>
  337. Below, please find a guide to the methods available in
  338. <classname>Zend_Loader_Autoloader</classname>.
  339. </para>
  340. <table id="zend.loader.autoloader.reference.api">
  341. <title>Zend_Loader_Autoloader Methods</title>
  342. <tgroup cols="4">
  343. <thead>
  344. <row>
  345. <entry>Method</entry>
  346. <entry>Return Value</entry>
  347. <entry>Parameters</entry>
  348. <entry>Description</entry>
  349. </row>
  350. </thead>
  351. <tbody>
  352. <row>
  353. <entry><methodname>getInstance()</methodname></entry>
  354. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  355. <entry>N/A</entry>
  356. <entry>
  357. <para>
  358. Retrieve the <classname>Zend_Loader_Autoloader</classname>
  359. singleton instance. On first retrieval, it registers
  360. itself with <code>spl_autoload</code>. This method is static.
  361. </para>
  362. </entry>
  363. </row>
  364. <row>
  365. <entry><methodname>resetInstance()</methodname></entry>
  366. <entry><code>void</code></entry>
  367. <entry>N/A</entry>
  368. <entry>
  369. <para>
  370. Resets the state of the
  371. <classname>Zend_Loader_Autoloader</classname> singleton instance to
  372. it's original state, unregistering all autoloader callbacks and all
  373. registered namespaces.
  374. </para>
  375. </entry>
  376. </row>
  377. <row>
  378. <entry><methodname>autoload($class)</methodname></entry>
  379. <entry><code>string|<constant>FALSE</constant></code></entry>
  380. <entry>
  381. <itemizedlist>
  382. <listitem>
  383. <para>
  384. <varname>$class</varname>, <emphasis>required</emphasis>.
  385. A string class name to load.
  386. </para>
  387. </listitem>
  388. </itemizedlist>
  389. </entry>
  390. <entry>
  391. <para>Attempt to resolve a class name to a file and load it.</para>
  392. </entry>
  393. </row>
  394. <row>
  395. <entry><methodname>setDefaultAutoloader($callback)</methodname></entry>
  396. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  397. <entry>
  398. <itemizedlist>
  399. <listitem>
  400. <para>
  401. <varname>$callback</varname>, <emphasis>required</emphasis>.
  402. </para>
  403. </listitem>
  404. </itemizedlist>
  405. </entry>
  406. <entry>
  407. <para>
  408. Specify an alternate <acronym>PHP</acronym> callback to use for the
  409. default autoloader implementation.
  410. </para>
  411. </entry>
  412. </row>
  413. <row>
  414. <entry><methodname>getDefaultAutoloader()</methodname></entry>
  415. <entry><code>callback</code></entry>
  416. <entry>N/A</entry>
  417. <entry>
  418. <para>
  419. Retrieve the default autoloader implementation; by default, this is
  420. <methodname>Zend_Loader::loadClass()</methodname>.
  421. </para>
  422. </entry>
  423. </row>
  424. <row>
  425. <entry><methodname>setAutoloaders(array $autoloaders)</methodname></entry>
  426. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  427. <entry>
  428. <itemizedlist>
  429. <listitem>
  430. <para>
  431. <varname>$autoloaders</varname>,
  432. <emphasis>required</emphasis>.
  433. </para>
  434. </listitem>
  435. </itemizedlist>
  436. </entry>
  437. <entry>
  438. <para>
  439. Set a list of concrete autoloaders to use in the
  440. autoloader stack. Each item in the autoloaders array
  441. must be a <acronym>PHP</acronym> callback.
  442. </para>
  443. </entry>
  444. </row>
  445. <row>
  446. <entry><methodname>getAutoloaders()</methodname></entry>
  447. <entry><type>Array</type></entry>
  448. <entry>N/A</entry>
  449. <entry><para>Retrieve the internal autoloader stack.</para></entry>
  450. </row>
  451. <row>
  452. <entry><methodname>getNamespaceAutoloaders($namespace)</methodname></entry>
  453. <entry><type>Array</type></entry>
  454. <entry>
  455. <itemizedlist>
  456. <listitem>
  457. <para>
  458. <varname>$namespace</varname>, <emphasis>required</emphasis>
  459. </para>
  460. </listitem>
  461. </itemizedlist>
  462. </entry>
  463. <entry>
  464. <para>
  465. Fetch all autoloaders that have registered to load a
  466. specific namespace.
  467. </para>
  468. </entry>
  469. </row>
  470. <row>
  471. <entry><methodname>registerNamespace($namespace)</methodname></entry>
  472. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  473. <entry>
  474. <itemizedlist>
  475. <listitem>
  476. <para>
  477. <varname>$namespace</varname>,
  478. <emphasis>required</emphasis>.
  479. </para>
  480. </listitem>
  481. </itemizedlist>
  482. </entry>
  483. <entry>
  484. <para>
  485. Register one or more namespaces with the default
  486. autoloader. If <varname>$namespace</varname> is a string,
  487. it registers that namespace; if it's an array of
  488. strings, registers each as a namespace.
  489. </para>
  490. </entry>
  491. </row>
  492. <row>
  493. <entry><methodname>unregisterNamespace($namespace)</methodname></entry>
  494. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  495. <entry>
  496. <itemizedlist>
  497. <listitem>
  498. <para>
  499. <varname>$namespace</varname>,
  500. <emphasis>required</emphasis>.
  501. </para>
  502. </listitem>
  503. </itemizedlist>
  504. </entry>
  505. <entry>
  506. <para>
  507. Unregister one or more namespaces from the default
  508. autoloader. If <varname>$namespace</varname> is a string,
  509. it unregisters that namespace; if it's an array of
  510. strings, unregisters each as a namespace.
  511. </para>
  512. </entry>
  513. </row>
  514. <row>
  515. <entry><methodname>getRegisteredNamespaces()</methodname></entry>
  516. <entry><type>Array</type></entry>
  517. <entry>N/A</entry>
  518. <entry>
  519. <para>
  520. Returns an array of all namespaces registered with the default
  521. autoloader.
  522. </para>
  523. </entry>
  524. </row>
  525. <row>
  526. <entry>
  527. <methodname>suppressNotFoundWarnings($flag = null)</methodname>
  528. </entry>
  529. <entry><code>boolean|Zend_Loader_Autoloader</code></entry>
  530. <entry>
  531. <itemizedlist>
  532. <listitem>
  533. <para>
  534. <varname>$flag</varname>, <emphasis>optional</emphasis>.
  535. </para>
  536. </listitem>
  537. </itemizedlist>
  538. </entry>
  539. <entry>
  540. <para>
  541. Set or retrieve the value of the flag used to
  542. indicate whether the default autoloader
  543. implementation should suppress "file not found"
  544. warnings. If no arguments or a <constant>NULL</constant> value is
  545. passed, returns a boolean indicating the status of the flag;
  546. if a boolean is passed, the flag is set to that
  547. value and the autoloader instance is returned (to
  548. allow method chaining).
  549. </para>
  550. </entry>
  551. </row>
  552. <row>
  553. <entry><methodname>setFallbackAutoloader($flag)</methodname></entry>
  554. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  555. <entry>
  556. <itemizedlist>
  557. <listitem>
  558. <para>
  559. <varname>$flag</varname>, <emphasis>required</emphasis>.
  560. </para>
  561. </listitem>
  562. </itemizedlist>
  563. </entry>
  564. <entry>
  565. <para>
  566. Set the value of the flag used to indicate whether
  567. or not the default autoloader should be used as a
  568. fallback or catch-all autoloader for all namespaces.
  569. </para>
  570. </entry>
  571. </row>
  572. <row>
  573. <entry><methodname>isFallbackAutoloader()</methodname></entry>
  574. <entry><type>Boolean</type></entry>
  575. <entry>N/A</entry>
  576. <entry>
  577. <para>
  578. Retrieve the value of the flag used to indicate whether
  579. or not the default autoloader should be used as a
  580. fallback or catch-all autoloader for all namespaces.
  581. By default, this is <constant>FALSE</constant>.
  582. </para>
  583. </entry>
  584. </row>
  585. <row>
  586. <entry><methodname>getClassAutoloaders($class)</methodname></entry>
  587. <entry><type>Array</type></entry>
  588. <entry>
  589. <itemizedlist>
  590. <listitem>
  591. <para>
  592. <varname>$class</varname>, <emphasis>required</emphasis>.
  593. </para>
  594. </listitem>
  595. </itemizedlist>
  596. </entry>
  597. <entry>
  598. <para>
  599. Get the list of namespaced autoloaders that could
  600. potentially match the provided class. If none match,
  601. all global (non-namespaced) autoloaders are returned.
  602. </para>
  603. </entry>
  604. </row>
  605. <row>
  606. <entry>
  607. <methodname>unshiftAutoloader($callback, $namespace = '')</methodname>
  608. </entry>
  609. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  610. <entry>
  611. <itemizedlist>
  612. <listitem>
  613. <para>
  614. <varname>$callback</varname>, <emphasis>required</emphasis>.
  615. A valid <acronym>PHP</acronym> callback
  616. </para>
  617. </listitem>
  618. <listitem>
  619. <para>
  620. <varname>$namespace</varname>,
  621. <emphasis>optional</emphasis>. A string representing a class
  622. prefix namespace.
  623. </para>
  624. </listitem>
  625. </itemizedlist>
  626. </entry>
  627. <entry>
  628. <para>
  629. Add a concrete autoloader implementation to the
  630. beginning of the internal autoloader stack. If a
  631. namespace is provided, that namespace will be used
  632. to match optimistically; otherwise, the autoloader
  633. will be considered a global autoloader.
  634. </para>
  635. </entry>
  636. </row>
  637. <row>
  638. <entry>
  639. <methodname>pushAutoloader($callback, $namespace = '')</methodname>
  640. </entry>
  641. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  642. <entry>
  643. <itemizedlist>
  644. <listitem>
  645. <para>
  646. <varname>$callback</varname>, <emphasis>required</emphasis>.
  647. A valid <acronym>PHP</acronym> callback
  648. </para>
  649. </listitem>
  650. <listitem>
  651. <para>
  652. <varname>$namespace</varname>,
  653. <emphasis>optional</emphasis>. A string representing a class
  654. prefix namespace.
  655. </para>
  656. </listitem>
  657. </itemizedlist>
  658. </entry>
  659. <entry>
  660. <para>
  661. Add a concrete autoloader implementation to the
  662. end of the internal autoloader stack. If a
  663. namespace is provided, that namespace will be used
  664. to match optimistically; otherwise, the autoloader
  665. will be considered a global autoloader.
  666. </para>
  667. </entry>
  668. </row>
  669. <row>
  670. <entry>
  671. <methodname>removeAutoloader($callback, $namespace = '')</methodname>
  672. </entry>
  673. <entry><classname>Zend_Loader_Autoloader</classname></entry>
  674. <entry>
  675. <itemizedlist>
  676. <listitem>
  677. <para>
  678. <varname>$callback</varname>, <emphasis>required</emphasis>.
  679. A valid <acronym>PHP</acronym> callback
  680. </para>
  681. </listitem>
  682. <listitem>
  683. <para>
  684. <varname>$namespace</varname>,
  685. <emphasis>optional</emphasis>. A string representing a class
  686. prefix namespace, or an array of namespace strings.
  687. </para>
  688. </listitem>
  689. </itemizedlist>
  690. </entry>
  691. <entry>
  692. <para>
  693. Remove a concrete autoloader implementation from
  694. the internal autoloader stack. If a namespace or
  695. namespaces are provided, the callback will be
  696. removed from that namespace or namespaces only.
  697. </para>
  698. </entry>
  699. </row>
  700. </tbody>
  701. </tgroup>
  702. </table>
  703. </sect2>
  704. </sect1>