I have a Slim Application with the following directory structure:
app/ vendor/ www/ config.php
In the app / I have the corresponding project files, in the providers / dependencies managed by the composer, and in the www / files available on the web server.
So, I'm going to create a Phar file line by line:
<?php $full_path = '/home/.../forms/'; $package_name = 'www/package.phar'; try { $phar = new Phar($full_path . $package_name, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $full_path . $package_name); $phar->startBuffering(); $phar->addFile($full_path . 'www/index.php'); $phar->addFile($full_path . 'www/bootstrap.php'); $phar->addFile($full_path . 'www/session_start.php'); // Grab config $phar->addFile($full_path . 'config.php'); $phar->buildFromIterator(new RecursiveIteratorIterator (new RecursiveDirectoryIterator('../app', FilesystemIterator::SKIP_DOTS)),'../app'); $phar->buildFromIterator(new RecursiveIteratorIterator (new RecursiveDirectoryIterator('../vendor', FilesystemIterator::SKIP_DOTS)),'../vendor'); $phar->setDefaultStub('bootstrap.php', 'bootstrap.php'); $phar->stopBuffering(); echo "Phar created."; } catch (Exception $e) { // handle errors here echo $e->getMessage(); }
So, I create this phar method, and then I have:
deploy.php
<?php require_once 'phar://package.phar/bootstrap.php'; $app->run();
But when accesing / deploy.php I get:
[Fri May 15 20:07:02 2015] [error] [client 10.0.2.2] PHP Warning: require_once (phar: //package.phar/bootstrap.php) [function.require-once]: failed open stream: cannot open the archive "/vagrant/www/package.phar", invalid alias in /vagrant/www/deploy.php on line 3 [Friday May 15 20:07:02 2015] [error] [client 10.0.2.2] PHP Fatal error: require_once () [function.require]: Could not open the window 'Lights: //package.phar/bootstrap.php' (include_path = '.: / usr / share / php: / usr / share / pear') in /vagrant/www/deploy.php on line 3
Do you think I should refer to him like that?
thanks
source share