Commit 3d8ba843 authored by Fabien Potencier's avatar Fabien Potencier

merged branch NoDiskInDriveA/master (PR #126)

Commits
-------

9c95e2f6 only execute phar stub on direct invocation of phar archive

Discussion
----------

Make silex.phar usable in CLI applications

Currently, requiring silex.phar in a CLI application that takes arguments is not possible, as the phar stub interferes with the execution of the application. I added a check to the stub which will execute the main stub code only if the phar file is directly invoked.
We ran into this issue when trying to reuse the dependency setup from our Silex-based web application in the Doctrine2 ORM CLI console application, which obviously requires arguments. I know Silex is not supposed to run command line applications, but being able to reuse already configured dependencies in a CLI application should be made possible.

---------------------------------------------------------------------------

by igorw at 2011/07/10 15:58:36 -0700

+1
parents 691406bf 9c95e2f6
......@@ -105,7 +105,7 @@ Phar::mapPhar('silex.phar');
require_once 'phar://silex.phar/autoload.php';
if ('cli' === php_sapi_name() && isset($argv[1])) {
if ('cli' === php_sapi_name() && basename(__FILE__) === $argv[0] && isset($argv[1])) {
switch ($argv[1]) {
case 'update':
$remoteFilename = 'http://silex-project.org/get/silex.phar';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment