cvs: peardoc /en/chapters pear2cs.xml
[email protected] ("Arnaud Limbourg")
| Newsgroups | php.pear.doc |
|---|---|
| Message-ID | <cvsarnaud1196541403@cvsserver> |
arnaud Sat Dec 1 20:36:43 2007 UTC
Modified files:
/peardoc/en/chapters pear2cs.xml
Log:
language tweaks
http://cvs.php.net/viewvc.cgi/peardoc/en/chapters/pear2cs.xml?r1=1.12&r2=1.13&diff_format=u
Index: peardoc/en/chapters/pear2cs.xml
diff -u peardoc/en/chapters/pear2cs.xml:1.12 peardoc/en/chapters/pear2cs.xml:1.13
--- peardoc/en/chapters/pear2cs.xml:1.12 Sat Dec 1 16:31:22 2007
+++ peardoc/en/chapters/pear2cs.xml Sat Dec 1 20:36:43 2007
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
-<!-- $Revision: 1.12 $ -->
+<!-- $Revision: 1.13 $ -->
<chapter id="pear2cs">
<chapterinfo>
<date>2007-11-26</date>
@@ -158,7 +158,7 @@
</para>
<para>
- In all cases, the bonus of loading needed files is shifted to the end
+ In all cases, the onus of loading needed files is shifted to the end
user. However, for beginning users, the only required step is to
load <filename>PEAR2/Autoload.php</filename>, which will be always bundled with new packages,
but only extracted if used as unzip-and-go (pyrus would simply install
@@ -173,9 +173,10 @@
]]>
</programlisting>
<filename>PEAR2/Autoload.php</filename> automatically sets up include_path if it does not
- contain the correct value, and also automatically declares
- <methodname>__autoload()</methodname> if
- the user has not defined it.
+ contain the correct value, and also automatically declares an autoloader
+ either using <methodname>__autoload()</methodname>
+ or <methodname>spl_autoload_register()</methodname>, preserving existing autoloaders set up by
+ the user.
</para>
</sect1>
@@ -266,34 +267,6 @@
</sect3>
</sect2>
- <sect2 id="pear2cs.rules.otherclasses">
- <title>Loading other classes</title>
- <para>
- Inside optional component loading methods (like factory or driver
- loading, etc.)
- <methodname>class_exists</methodname>($classname, true) should be used where a "class not found"
- fatal error
- would be confusing. For example, when loading a driver, a graceful exit
- via exception
- with helpful error message is preferrable to the fatal error:
- </para>
- <programlisting role="php">
- <![CDATA[
-<?php
-if (!class_exists("PEAR2_PackageName_Driver_$class", true)) {
- throw new PEAR2::PackageName::Exception('Unknown driver ' .
- $class . ', be sure the driver exists and is loaded
- prior to use');
-}
-?>
- ]]>
- </programlisting>
- <sect3 id="pear2cs.rules.otherclasses.requirement">
- <title>Requirement</title>
- <simpara>This rule is optional and is a suggested coding practice</simpara>
- </sect3>
- </sect2>
-
<sect2 id="pear2cs.rules.dirstructure">
<title>Directory structure</title>
<para>Follows the directory structure in the PEAR2 Subversion
@@ -383,8 +356,9 @@
The installation structure of a package has implicit
<literal>php_dir/src</literal>
installation location, and data files are always located in
- <literal>php_dir/data/channel/PackageName/</literal>. To retrieve a data file within
- <literal>PEAR2/PackageName/Subfile.php</literal>, you would use this code:
+ <literal>php_dir/data/channel/PackageName/</literal>. To retrieve a data
+ file within <filename>PEAR2/PackageName/Subfile.php</filename>, you could
+ use code like this example
</para>
<programlisting role="php">
<![CDATA[
@@ -401,6 +375,35 @@
<simpara>No Exceptions to this rule</simpara>
</sect3>
</sect2>
+
+ <sect2 id="pear2cs.rules.otherclasses">
+ <title>Loading other classes</title>
+ <para>
+ Inside optional component loading methods (like factory or driver
+ loading, etc.)
+ <methodname>class_exists</methodname>($classname, true) should be used where a "class not found"
+ fatal error
+ would be confusing. For example, when loading a driver, a graceful exit
+ via exception
+ with helpful error message is preferrable to the fatal error:
+ </para>
+ <programlisting role="php">
+ <![CDATA[
+<?php
+if (!class_exists("PEAR2_PackageName_Driver_$class", true)) {
+ throw new PEAR2::PackageName::Exception('Unknown driver ' .
+ $class . ', be sure the driver exists and is loaded
+ prior to use');
+}
+?>
+ ]]>
+ </programlisting>
+ <sect3 id="pear2cs.rules.otherclasses.requirement">
+ <title>Requirement</title>
+ <simpara>This rule is optional and is a suggested coding practice</simpara>
+ </sect3>
+ </sect2>
+
</sect1>
</chapter>