Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

3 participants

@zolex

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.

@michaelperrin

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.

@stof
Collaborator

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.
@michaelperrin

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!

@stof
Collaborator

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
View
43 package-composer.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Phing alternative to packaging the PHAR:
+ * $ php package.php
+ *
+ * @author Eric Clemmons <eric@smarterspam.com>
+ */
+
+chdir(dirname(dirname(dirname(__DIR__))));
+
+$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);
+$p->CompressFiles(Phar::GZ);
+$p->setSignatureAlgorithm(Phar::SHA1);
+
+$p->startBuffering();
+
+$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->stopBuffering();
+
+$p->setStub(file_get_contents(__DIR__ . '/phar-cli-stub.php'));
Something went wrong with that request. Please try again.