diff --git a/bin/doctrine b/bin/doctrine index 92f323f8c..c359ca7d8 100644 --- a/bin/doctrine +++ b/bin/doctrine @@ -1,4 +1,4 @@ #!/usr/bin/env php . + */ + +require_once 'Doctrine/Common/ClassLoader.php'; + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony'); +$classLoader->register(); + +$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; + +$helperSet = null; +if (file_exists($configFile)) { + if ( ! is_readable($configFile)) { + trigger_error( + 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR + ); + } + + require $configFile; + + foreach ($GLOBALS as $helperSetCandidate) { + if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { + $helperSet = $helperSetCandidate; + break; + } + } +} + +$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); + +\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet); diff --git a/bin/doctrine.php b/bin/doctrine.php index 701038488..3ce1d4f40 100644 --- a/bin/doctrine.php +++ b/bin/doctrine.php @@ -17,12 +17,17 @@ * . */ -require_once 'Doctrine/Common/ClassLoader.php'; +if (!@include __DIR__ . '/../../../autoload.php') { + die(<<<'EOT' +This command can only be run when Doctrine is installed through Composer. +EOT + ); +} $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine'); +$classLoader = new \Doctrine\Common\ClassLoader('Symfony'); $classLoader->register(); $configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; diff --git a/build.xml b/build.xml index a2379c654..890ed05bc 100644 --- a/build.xml +++ b/build.xml @@ -19,7 +19,7 @@ --> - + @@ -104,7 +104,7 @@ Symfony/Component/Console/ - + diff --git a/composer.json b/composer.json index 0c7652d37..05713321e 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,16 @@ "require": { "php": ">=5.3.2", "ext-pdo": "*", - "doctrine/dbal": "2.3.*" + "doctrine/dbal": "2.3.*", + "symfony/console": "2.*" + }, + "suggest": { + "symfony/yaml": "If you want to using YAML Metadata Mapping Driver" }, "autoload": { "psr-0": { "Doctrine\\ORM": "lib/" } }, + "bin": ["bin/doctrine", "bin/doctrine.php"], "extra": { "branch-alias": { "dev-master": "2.3.x-dev"