Permalink
Browse files

Use Composer autoloader

  • Loading branch information...
1 parent f17f2dc commit 813641139b0ee19b8aa9ba9bff71e2c64ad83e1e @willdurand willdurand committed Dec 19, 2011
Showing with 60 additions and 43 deletions.
  1. +3 −1 README.md
  2. +26 −15 autoload.php.dist
  3. +0 −3 bin/propel.php
  4. +30 −19 composer.json
  5. +1 −5 tests/bootstrap.php
View
@@ -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.
View
@@ -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();
+}
View
@@ -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')) {
View
@@ -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",
@stloyd

stloyd Dec 19, 2011

IMO you should skip version or append it with -DEV keyword ;-)

@stloyd

stloyd Dec 19, 2011

Because version 2.0 is not yet stable and/or released ? It's confusing (at least for me) ;-)

@willdurand

willdurand Dec 19, 2011

Owner

Yeah, just for you :p

All master branches are considered as dev in composer/packagist. So there is nothing wrong here.

+ "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"
+ ]
}
View
@@ -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.