1
0
mirror of synced 2025-01-18 22:41:43 +03:00

Enhanced Bootstrap Section for more information on Autoloading in different setups (PEAR vs Git)

This commit is contained in:
Benjamin Eberlei 2010-07-22 22:55:00 +02:00
parent b1f6fe2528
commit 439cccbc0d

View File

@ -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 > 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. > 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** > **NOTE**
> This assumes you've created some kind of script to test the following code in. > This assumes you've created some kind of script to test the following code in.
> Something like a `test.php` file. > Something like a `test.php` file.
++++ PEAR or Tarball Download
[php] [php]
// test.php // test.php
require '/path/to/lib/Doctrine/Common/ClassLoader.php'; require '/path/to/libraries/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', '/path/to/Doctrine2/lib'); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', '/path/to/libraries');
$classLoader->register(); // register on SPL autoload stack $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. 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 +++ Obtaining an EntityManager