2012-06-18 12 views

Antwort

11

Es ist einfach durch Ändern der Standard-Stub (Hinzufügen der Shebang entsprechend PHP).

// start buffering. Mandatory to modify stub. 
$phar->startBuffering(); 

// Get the default stub. You can create your own if you have specific needs 
$defaultStub = $phar->createDefaultStub('index.php'); 

// Adding files 
$phar->buildFromDirectory(__DIR__, '/\.php$/'); 

// Create a custom stub to add the shebang 
$stub = "#!/usr/bin/php \n".$defaultStub; 

// Add the stub 
$phar->setStub($stub); 

$phar->stopBuffering(); 
+9

Da die ausführbare PHP-Datei ist nicht in '/ usr/bin/php' auf allen Systemen, ist es besser,' # zu verwenden!/Usr/bin/env php' statt. Siehe http://tech.vg.no/2012/02/21/dont-hardcode-php-executable-path-in-shebang/ – chiborg

+0

Aus irgendeinem Grund funktionierte es nicht auf meinem Ubuntu-Server 10.04LTS ... – magnetik

+0

Funktioniert diese Methode unter Windows? – weynhamz

Verwandte Themen