<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="yaf-loader.registerlocalnamespace" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Yaf_Loader::registerLocalNamespace</refname>
  <refpurpose>Register local class prefix</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>void</type><methodname>Yaf_Loader::registerLocalNamespace</methodname>
   <methodparam><type>mixed</type><parameter>prefix</parameter></methodparam>
  </methodsynopsis>
  <para>
   Register local class prefix name, <classname>Yaf_Loader</classname> search
   classes in two library directories, the one is configured via <link
    linkend="configuration.yaf.library">application.library.directory</link>(in
   application.ini) which is called local libraray directory; the other is
   configured via <link linkend="ini.yaf.library">yaf.library</link> (in
   php.ini) which is callled global library directory, since it can be shared
   by many applications in the same server. 
  </para>
  <para>
   When an autloading is trigger, <classname>Yaf_Loader</classname> will
   determine which library directory should be searched in by exame the prefix
   name of the missed classname.

   If the prefix name is registered as a localnamespack then look for it in
   local library directory, otherwise look for it in global library directory.
   <note>
    <para>
     If yaf.library is not configured, then the global library directory is
     assumed to be the local library directory. in that case, all autoloading
     will look for local library directory. 

     But if you want your Yaf application be strong, then always register your
     own classes as local classes.
    </para>
   </note>
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>prefix</parameter></term>
    <listitem>
     <para>
      a string or a array of class name prefix.
      all class prefix with these prefix will be loaded in local library path.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   bool
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Yaf_Loader::registerLocalNamespace</function>example</title>
   <programlisting role="php">
<![CDATA[
<?php
$loader = Yaf_Loader::getInstance('/local/library/', '/global/library');
$loader->registerLocalNamespace("Baidu");
$loader->registerLocalNamespace(array("Sina", "Weibo"));

$loader->autoload("Baidu_Name"); // search in '/local/library/'
$loader->autoload("Sina");       // search '/local/library/'
$loader->autoload("Global_Name");// search in '/global/library/'
$loader->autoload("Foo_Bar");    // search in '/global/library/'

?>
]]>
   </programlisting>
  </example>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
