I know how to convert php file into phar file.
$phar = new PHAR('app.phar');
$phar->addFile('file1.php');
$phar->addFile('file2.php');
I thought it can be useful only for converting POPO to PHAR.
My question
Is it possible to convert entire Zend framework 2 web application to PHAR file? if yes, then How?
(or)
How to package Zend framework2 web application into a package? (except .zpk(zend studio package file) file format)
create-phar.php
$basePath = /path/to/;
$path = /path/to/application;
$phar = new Phar ('project.phar');
$phar->buildFromIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)), $basePath);
$phar->setStub("<?php
Phar::webPhar('project', 'public/index.php');
include 'phar://project/public/index.php';
__HALT_COMPILER();
?>");
index.php
<?php
include 'project.phar';
?>
Question:
When i run index.php it do not redirect to actual public/index.php file instead it shows blank page on the browser. How can I resolve this problem?
Thanks in advance
I deploy phorkie as a .phar
file.
There are some things to consider:
.phar
- php and static asset files (js, css, png, jpg), too. I use phing to do that. Do not forget the dependencies.Phar::webPhar()
which takes care of sending out HTTP headers.htaccess
rewrite rule interpreter, because Phar::webPhar()
does not do nice-path resolving on its own. I did that already.Phar::webPhar
bugs:
.phar
files (it will not; neither Debian nor Fedora ship that configuration).phar
files with PATH_INFO
appended (/path/to/file.phar/foo/bar.png
), like in http://p.cweiske.de/122Getting phorkie running from the .phar
took me the evenings of two weeks. Now that it basically works it still is not a drop-phar-and-play solution, because the default configuration of web servers just doesn't play nice with .phar
.