Permalink
Browse files

[DDC-1807] Fix composer bin support and keep BC with PEAR installer.

  • Loading branch information...
1 parent e2d15c3 commit be6fb617dfc494acec144ba058fc708f02a54f61 @beberlei beberlei committed May 22, 2012
Showing with 66 additions and 6 deletions.
  1. +1 −1 bin/doctrine
  2. +50 −0 bin/doctrine-pear.php
  3. +7 −2 bin/doctrine.php
  4. +2 −2 build.xml
  5. +6 −1 composer.json
View
@@ -1,4 +1,4 @@
#!/usr/bin/env php
<?php
-include('doctrine.php');
+include('doctrine.php');
View
@@ -0,0 +1,50 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+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);
View
@@ -17,12 +17,17 @@
* <http://www.doctrine-project.org>.
*/
-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');
@stof

stof May 22, 2012

Member

why registering autoloaders relying on the include path here ? The autoloader will already have been registered by the composer file

@beberlei

beberlei May 22, 2012

Owner

you are right, forgot to remove that.

$classLoader->register();
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
View
@@ -19,7 +19,7 @@
-->
<fileset id="bin-scripts" dir="./bin">
<include name="doctrine"/>
- <include name="doctrine.php"/>
+ <include name="doctrine-pear.php"/>
<include name="doctrine.bat"/>
</fileset>
@@ -104,7 +104,7 @@
<ignore>Symfony/Component/Console/</ignore>
<release>
<install as="doctrine" name="bin/doctrine" />
- <install as="doctrine.php" name="bin/doctrine.php" />
+ <install as="doctrine.php" name="bin/doctrine-pear.php" />
<install as="doctrine.bat" name="bin/doctrine.bat" />
</release>
<replacement path="bin/doctrine" type="pear-config" from="@php_bin@" to="php_bin" />
View
@@ -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"],
@Seldaek

Seldaek May 31, 2012

Member

If you used include(__DIR__.'/doctrine.php'); in the doctrine script, you could just add that one instead of having the two in bin, because that's kinda polluting the bin dir with useless files.

@pierrre

pierrre Aug 3, 2012

In my Symfony2 project, I get a new "bin" folder.
Should I gitignore it?

"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev"

0 comments on commit be6fb61

Please sign in to comment.