Reputation: 22947
In the /app/
directory in Laravel 4, there is a file called server.php
. The contents of this file look like this:
<?php
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = urldecode($uri);
$paths = require __DIR__.'/bootstrap/paths.php';
$requested = $paths['public'].$uri;
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' and file_exists($requested))
{
return false;
}
require_once $paths['public'].'/index.php';
It seems that this file is in someway used to mimic Apache's mod_rewrite
functionality, however I cannot find anything in the Laravel documentation that mentions it or it's use.
I currently am trying to utilize Laravel on an IIS server that I do not manage. I do not have the ability to modify the URL rewrite module options on IIS (I will in the future), but would like to get started working with the framework now, if possible. This server.php
file seems like it may be a stop-gap solution to do just that.
Can anyone shed some light on the purpose of the server.php
file and how to use/activate it if the purpose is really to emulate Apache's mod_rewrite
functionality?
Upvotes: 45
Views: 31073
Reputation: 8471
It is meant to be used with PHP's internal web server which was introduced in PHP 5.4.
According to the PHP manual:
This web server is designed for developmental purposes only, and should not be used in production.
I can't emphasize this enough.
If you would like to use it with the Laravel server.php
file you can head to your cli and start the server with the following command (from the root of your Laravel directory):
php -S localhost:8000 server.php
You should then be able to head to localhost:8000
in your web browser and begin using your Laravel application.
Alternatively as Anand Capur mentioned you can launch the server with:
php artisan serve
Ultimately this just runs the aforementioned php -S
command for you.
You can optionally specify the host
and port
by doing something like:
php artisan serve --port=8080 --host=local.dev
As with all artisan
commands you can find out this information and additional information by doing:
php artisan serve --help
Upvotes: 64
Reputation: 818
You can also use the command
artisan serve
which will run the appropriate command to start the development server.
Upvotes: 14