Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


added script to allow phar packaging with libs installed by composer #92

wants to merge 1 commit into from

3 participants


this is simply a copy of package.php with changes to the paths which allow builing the phar when doctrine migrations was installed using composer.


This pull request should definitely be merged as Composer is the new way to handle dependencies and that using the usual package.php file doesn't work anymore.


Actually, I would prefer removing this script entirely. Doctrine is not building this phar anywhere AFAIK, and people wanting to use a phar could use Box to build it.
Thus, I don't think it make much sense to build a phar for Doctrine Migrations:

  • a standalone phar does not make sense as it depends on other libraries. So you would have to download several other phars to have a working one, or use composer to get them (in which case you should also get this lib through composer)
  • a phar including the deps means you would end with duplicated versions of Doctrine DBAL in your project.

That's a good point!

However, I was actually trying to build a standalone phar archive as it makes sense to use Doctrine Migrations in legacy PHP projects that don't use Doctrine. I like Doctrine Migrations as a simple but useful database versioning tool that can be easily deployed for older projects. Liquibase and such are much bigger projects.

In that way, deploying a simple file phar file (including unfortunately all the depencies) seemed to me a convenient solution.

I didn't know about the Box project, which seems interesting though for my needs!


Closing in favor of #97

@stof stof closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 43 additions and 0 deletions.
  1. +43 −0 package-composer.php
43 package-composer.php
@@ -0,0 +1,43 @@
+ * Phing alternative to packaging the PHAR:
+ * $ php package.php
+ *
+ * @author Eric Clemmons <>
+ */
+$buildDir = realpath(dirname(__FILE__)) . '/build';
+$pharName = "$buildDir/doctrine-migrations.phar";
+if (!file_exists($buildDir)) {
+ mkdir($buildDir);
+if (file_exists($pharName)) {
+ unlink($pharName);
+$p = new Phar($pharName);
+$dirs = array(
+ 'vendor/doctrine/migrations/lib' => '/Doctrine/',
+ 'vendor/doctrine/dbal/lib' => '/Doctrine/',
+ 'vendor/doctrine/common/lib' => '/Doctrine/',
+ 'vendor/symfony/console' => '/Symfony/'
+foreach ($dirs as $dir => $filter) {
+ $p->buildFromDirectory($dir, $filter);
+$p->setStub(file_get_contents(__DIR__ . '/phar-cli-stub.php'));
Something went wrong with that request. Please try again.