2012-06-18 26 views

risposta

11

È facile modificando lo stub predefinito (aggiungendo lo shebang corrispondente a 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

Dal momento che l'eseguibile di PHP non è in '/ usr/bin/php' su tutti i sistemi, è meglio usare' #!/Usr/bin/env php' invece. Vedere http://tech.vg.no/2012/02/21/dont-hardcode-php-executable-path-in-shebang/ – chiborg

+0

Per qualche motivo non funzionava sul mio server Ubuntu 10.04 LTS ... – magnetik

+0

Questo metodo funziona su Windows? – weynhamz

Problemi correlati