Permalink
Browse files

Merge branch 'release-0.7.1'

  • Loading branch information...
2 parents c73f111 + 68e140f commit dea4cb068a71c5ee634b06400032f53df5444822 @trq trq committed Nov 27, 2012
Showing with 2,381 additions and 5 deletions.
  1. +6 −4 Phakefile
  2. +115 −0 doc/autoloader.twig
  3. +319 −0 doc/bootstrap.twig
  4. +99 −0 doc/controllers.twig
  5. +192 −0 doc/dispatch.twig
  6. +101 −0 doc/filter.twig
  7. +69 −0 doc/index.twig
  8. +105 −0 doc/installation.twig
  9. +164 −0 doc/io.twig
  10. +160 −0 doc/modules.twig
  11. +88 −0 doc/plugins.twig
  12. +195 −0 doc/quickstart.twig
  13. +268 −0 doc/route-component.twig
  14. +272 −0 doc/services-component.twig
  15. +227 −0 doc/signal-component.twig
  16. +1 −1 lib/Proem/Proem.php
View
@@ -49,8 +49,10 @@ group('dev', function() {
$phar->buildFromDirectory('.');
$phar->setStub("<?php
Phar::mapPhar('proem.phar');
- require_once 'phar://proem.phar/Proem/Autoloader.php';
- (new Proem\Autoloader())->attachNamespaces(['Proem' => 'phar://proem.phar'])->register();
+ require_once 'phar://proem.phar/Proem/Util/Autoloader.php';
+ (new Proem\\Util\\Autoloader(false))
+ ->attachNamespace('Proem', 'phar://proem.phar')
+ ->register();
__HALT_COMPILER();
?>");
rename('proem.phar', '../build/proem.phar');
@@ -62,7 +64,7 @@ group('dev', function() {
desc('Bump the version number');
task('bump', function($args) {
- $file = file_get_contents('lib/Proem/Api/Proem.php');
+ $file = file_get_contents('lib/Proem/Proem.php');
preg_match('/VERSION = \'([0-9]?)\.([0-9]?)\.([a-z0-9])\';/', $file, $matches);
list($all, $major, $minor, $incr) = $matches;
if (isset($args['major'])) {
@@ -83,7 +85,7 @@ group('dev', function() {
echo "VERSION = '$version'\n";
if (isset($args['write'])) {
$file = preg_replace('/VERSION = \'(.*)\';/', "VERSION = '$version';", $file);
- file_put_contents('lib/Proem/Api/Proem.php', $file);
+ file_put_contents('lib/Proem/Proem.php', $file);
}
});
});
View
@@ -0,0 +1,115 @@
+{% extends 'docs_layout.twig' %}
+{% block content %}
+<div class="well">
+ <h2>The Autoloader</h2>
+ <p>
+ The autoloader is a simple class loader which adheres to the recently defined PSR-0 standard
+ (see <a href="http://groups.google.com/group/php-standards">here</a> and <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md">here</a>).
+ </p>
+ <p>
+ Whenever you attempt to use a class which has not yet been included PHP will trigger a mechanism
+ which looks for a registered autoloader. This autoloader can then be used to search the file system
+ for the file required to load the class.
+ </p>
+ <p>
+ If the <a href="http://php.net/apc">APC</a> caching extension is enabled in your servers configuration Proem's Autoloader will automatically
+ make use of this extension, thus optimising class lookups by storing the location of a class within the cache.
+ <p>
+ Proem's Autoloader is simple to use and enables lazy loading of both the Proem libraries as well
+ as any third party code complying with the <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md">PSR-0 standard</a>.
+ </p>
+ <p>
+ The following example illustrates all the code you need within your bootstrap to be able to use Proem.
+ </p>
+</div>
+<div class="well">
+ <h3>A simple example</h3>
+ <pre class="prettyprint">
+ require_once './lib/Proem/Util/Autoloader.php';
+
+ (new \Proem\Util\AutoLoader)
+ ->register();
+ </pre>
+ <div class="alert alert-info">
+ Note that you first must manually include the {{ hubLink('Proem.Util.Autoloader') }} file itself. Once this is done, you will no longer need any calls to include or require within your
+ code and Proem is included by default.
+ </div>
+</div>
+<div class="well">
+ <h3>Attaching namespaces</h3>
+ <p>The Proem autloader expects namespaces mapped to the paths these namespaces can be found within (or more commonly, there parent directory):</p>
+ <pre class="prettyprint">
+ (new \Proem\Util\AutoLoader)
+ ->attachNamespace([
+ 'Foo' => '/myfoo'
+ ]);
+ </pre>
+ <div class="alert alert-info">
+ As of {{ commitLink('f3d110d') }} the following will also now work.
+ </div>
+ <pre class="prettyprint">
+ (new \Proem\Util\AutoLoader)
+ ->attachNamespace([
+ 'Foo' => '/myfoo/Foo'
+ ]);
+ </pre>
+</div>
+<div class="well">
+ <h3>Multiple locations for a single namespace</h3>
+ <p>You can also register multiple file system paths for a single name space to reside in:</p>
+ <pre class="prettyprint">
+ (new \Proem\AutoLoader)
+ ->attachNamespace([
+ 'Foo' => ['/morefoo', '/myfoo']
+ ]);
+ </pre>
+ <p>
+ Here, the first path registered will be searched first. So, if you have a class in <em>/myfoo/Foo/Foo.php</em>
+ and code which instantiates <em>Foo\Foo</em> the Proem class will be loaded from <em>/morefoo/Foo/Foo.php</em>
+ and not <em>/myfoo/Foo/Foo.php</em>
+ </p>
+</div>
+<div class="well">
+ <h3>Loading PEAR like classes</h3>
+ <p>
+ Classes implementing the PEAR naming conventions can also be added to the autoloader as defined by PSR-0:
+ </p>
+ <pre class="prettyprint">
+ (new \Proem\AutoLoader())
+ ->attachPearPrefix('Pear_', '/usr/share/php');
+ </pre>
+ <p>
+ This tells the autoloader to find classes beginning with the prefix Pear_ within the /usr/share/php directory.
+ There are similar methods for adding multiple Pear type prefixes and locations as there are with name spaces.
+ </p>
+ <p>
+ While you can add as many namespaces &amp; paths as are required prior to calling the register() method
+ you can also, if need be, register a completely new Autoloader at a latter time.
+ </p>
+ <pre class="prettyprint">
+ require_once 'Proem/Autoloader.php';
+
+ (new \Proem\AutoLoader())
+ ->register();
+
+ // some more code
+
+ (new \Proem\AutoLoader())
+ ->attachNamespace('Foo', './foo')
+ ->register();
+
+ // more code using the Foo namespace
+ </pre>
+ <p>
+ You can also unregister an Autoloader simply:
+ </p>
+ <pre class="prettyprint">
+ $autoloader = (new \Proem\AutoLoader());
+
+ // some code making use of $autoloader
+
+ $autoloader->unregister();
+ </pre>
+</div>
+{{ disqus('/docs/autoloader') }}
+{% endblock %}
Oops, something went wrong.

0 comments on commit dea4cb0

Please sign in to comment.