Skip to content

Commit

Permalink
Use Composer autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Dec 19, 2011
1 parent f17f2dc commit 8136411
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 43 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.3.

Propel2 uses the following Symfony2 Components:

* [ClassLoader](https://github.com/symfony/ClassLoader)
* [Console](https://github.com/symfony/Console)
* [Yaml](https://github.com/symfony/Yaml)

Propel2 also relies on [**Composer**](https://github.com/composer/composer) to manage dependencies but you
also can use [ClassLoader](https://github.com/symfony/ClassLoader) (see the `autoload.php.dist` file for instance).

Propel2 is only supported on PHP 5.3.3 and up.


Expand Down
41 changes: 26 additions & 15 deletions autoload.php.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<?php

if (!class_exists('\Symfony\Component\ClassLoader\UniversalClassLoader')) {
require_once __DIR__ . '/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php';
}
if (file_exists($file = __DIR__.'/vendor/.composer/autoload.php')) {
$loader = require $file;

$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(array(
'Foo' => __DIR__ . '/tests/Fixtures/namespaced/build/classes',
'Baz' => __DIR__ . '/tests/Fixtures/namespaced/build/classes',
'Propel\Tests' => array(
$loader->add('Foo', __DIR__ . '/tests/Fixtures/namespaced/build/classes');
$loader->add('Baz', __DIR__ . '/tests/Fixtures/namespaced/build/classes');
$loader->add('Propel\Tests', array(
__DIR__ . '/tests',
__DIR__ . '/tests/Fixtures/bookstore/build/classes',
__DIR__ . '/tests/Fixtures/schemas/build/classes',
),
'Propel\Runtime' => __DIR__ . '/src',
'Propel\Generator' => __DIR__ . '/src',
'Symfony\Component' => __DIR__ . '/vendor',
));
$loader->register();
__DIR__ . '/tests/Fixtures/schemas/build/classes'
));
$loader->register();
} elseif (file_exists($file = __DIR__ . '/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php')) {
require_once $file;

$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(array(
'Propel\Runtime' => __DIR__ . '/src',
'Propel\Generator' => __DIR__ . '/src',
'Symfony\Component' => __DIR__ . '/vendor',
'Foo' => __DIR__ . '/tests/Fixtures/namespaced/build/classes',
'Baz' => __DIR__ . '/tests/Fixtures/namespaced/build/classes',
'Propel\Tests' => array(
__DIR__ . '/tests',
__DIR__ . '/tests/Fixtures/bookstore/build/classes',
__DIR__ . '/tests/Fixtures/schemas/build/classes',
),
));
$loader->register();
}
3 changes: 0 additions & 3 deletions bin/propel.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

if (!class_exists('\Symfony\Component\Console\Application')) {
if (file_exists($file = __DIR__.'/../vendor/.composer/autoload.php')) {
require_once $file;
}
if (file_exists($file = __DIR__.'/../autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/../autoload.php.dist')) {
Expand Down
49 changes: 30 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
{
"name": "propel/propel",
"type": "library",
"description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.3",
"keywords": ["ORM", "persistence", "Active Record"],
"homepage": "http://www.propelorm.org/",
"version": "2.0.0",
"license": "MIT",
"authors": [
{
"name": "William Durand",
"email": "william.durand1@gmail.com"
}
],
"require": {
"php": ">=5.3.2",
"symfony/class-loader": ">=2.0",
"symfony/yaml": ">=2.0",
"symfony/console": ">=2.0"
}
"name": "propel/propel",
"type": "library",
"description": "Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.3",
"keywords": [
"ORM",
"persistence",
"Active Record"
],
"homepage": "http://www.propelorm.org/",
"version": "2.0.0",
"license": "MIT",
"authors": [
{
"name": "William Durand",
"email": "william.durand1@gmail.com"
}
],
"require": {
"php": ">=5.3.2",
"symfony/yaml": ">=2.0",
"symfony/console": ">=2.0"
},
"autoload": {
"psr-0": {
"Propel": "src/"
}
},
"bin": [
"bin/propel"
]
}
6 changes: 1 addition & 5 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<?php

if (file_exists($file = __DIR__.'/../autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/../autoload.php.dist')) {
require_once $file;
}
require_once __DIR__.'/../autoload.php.dist';

0 comments on commit 8136411

Please sign in to comment.