Enhanced Bootstrap Section for more information on Autoloading in different setups (PEAR vs Git)
This commit is contained in:
parent
b1f6fe2528
commit
439cccbc0d
@ -23,19 +23,55 @@ and namespace and where there is a common root namespace.
|
||||
> meant to be only used for Doctrine classes, too. It is a generic class loader that can
|
||||
> be used for any classes that follow some basic naming standards as described above.
|
||||
|
||||
The following example shows the setup of a `ClassLoader`
|
||||
The following example shows the setup of a `ClassLoader` for the different types
|
||||
of Doctrine Installations:
|
||||
|
||||
> **NOTE**
|
||||
> This assumes you've created some kind of script to test the following code in.
|
||||
> Something like a `test.php` file.
|
||||
|
||||
++++ PEAR or Tarball Download
|
||||
|
||||
[php]
|
||||
// test.php
|
||||
|
||||
require '/path/to/lib/Doctrine/Common/ClassLoader.php';
|
||||
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', '/path/to/Doctrine2/lib');
|
||||
require '/path/to/libraries/Doctrine/Common/ClassLoader.php';
|
||||
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', '/path/to/libraries');
|
||||
$classLoader->register(); // register on SPL autoload stack
|
||||
|
||||
++++ Git
|
||||
|
||||
The Git bootstrap assumes that you have fetched the related packages through `git submodule update --init`
|
||||
|
||||
[php]
|
||||
// test.php
|
||||
|
||||
$lib = '/path/to/doctrine2-orm/lib/';
|
||||
require $lib . 'vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', $lib . 'vendor/doctrine-common/lib');
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', $lib . 'vendor/doctrine-dbal/lib');
|
||||
$classLoader->register();
|
||||
|
||||
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', $lib);
|
||||
$classLoader->register();
|
||||
|
||||
++++ Additional Symfony Components
|
||||
|
||||
If you don't use Doctrine2 in combination with Symfony2 you have to register an additional namespace to be able to use
|
||||
the Doctrine-CLI Tool or the YAML Mapping driver:
|
||||
|
||||
[php]
|
||||
// PEAR or Tarball setup
|
||||
$classloader = new \Doctrine\Common\ClassLoader('Symfony', '/path/to/libraries/Doctrine');
|
||||
$classloader->register();
|
||||
|
||||
// Git Setup
|
||||
$classloader = new \Doctrine\Common\ClassLoader('Symfony', $lib . 'vendor/');
|
||||
$classloader->register();
|
||||
|
||||
For best class loading performance it is recommended that you keep your include_path short, ideally it should only contain the path to the PEAR libraries, and any other class libraries should be registered with their full base path.
|
||||
|
||||
+++ Obtaining an EntityManager
|
||||
|
Loading…
x
Reference in New Issue
Block a user