Commit 197d2400 authored by Igor Wiedler's avatar Igor Wiedler

Fix PHP 5.4 built-in webserver front controller

The problem is that with `php -S localhost:8080 -t web` it will only route
one level of paths to index.php. This is stupid, but requires us to use
a router script, which means that we must specify `index.php` and have
that script return false when the web server should serve from disk.

Funny part: We are almost lying now, because the webserver now requires
some sort of configuration (via code), but I will leave it in the docs
for marketing reasons. It's not a big lie after all.
parent 13eb2ba9
...@@ -107,13 +107,27 @@ PHP 5.4 ...@@ -107,13 +107,27 @@ PHP 5.4
------- -------
PHP 5.4 ships with a built-in webserver for development. This server allows PHP 5.4 ships with a built-in webserver for development. This server allows
you to run silex without any configuration. Assuming your front controller is you to run silex without any configuration. However, in order to serve static
at ``web/index.php``, you can start the server from the command-line with this files, you'll have to make sure your front controller returns false in that
command: case::
// web/index.php
$filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
return false;
}
$app = require __DIR__.'/../src/app.php';
$app->run();
Assuming your front controller is at ``web/index.php``, you can start the
server from the command-line with this command:
.. code-block:: text .. code-block:: text
$ php -S localhost:8080 -t web $ php -S localhost:8080 -t web web/index.php
Now the application should be running at ``http://localhost:8080``. Now the application should be running at ``http://localhost:8080``.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment