How to run a webphar PHP file from built-in PHP 5.4 webserver?
phar, php, php-5.4
Solution
`php -S localhost:80 -t /path/to/phar` isn't going to work since the `-t` argument is meant to be used for directories. The trick is that the php webserver supports passing a router as argument. Therefore, suppose your phar is in /tmp (it can be anywhere), this is how you create a simple router, and setup the webserver:
echo '<?php require("/path/to/phar");'>/tmp/router.php
php -S localhost:80 /tmp/router.php
Problem
As per title, I created a very simple test phar. I'd like to test it with the built-in webserver(PHP 5.4) but it seems impossible. ``` php -S localhost:80 /path/to/myphar.php ``` Result: blank page (in the phar front controller is `index.php` doing some HTML output). ``` php -S localhost:80 -t /path/to/folder_with_index_and_phar ``` With loader script: ``` <?php require 'phar://myphar.php' ``` Result in a blank page, again. Is this even possible or I have to use Apache? EDIT: after an year I need this again. Here is what's happening (from answers): ``` php -S localhost:80 -t /path/to/app.phar php -S localhost:80 -t /path/to/app.phar ``` Results in an error: /path/to/app.phar is not a directory. While: ``` php -S localhost:80 -t . http://localost/app.phar/foo/bar ``` Works, but I don't need the app.phar "prefix"! Using Apache and setting the directory index to app.phar works as expected.