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?
By default, Laravel is configured to use MySQL, and you will need to supply connection credentials within the database configuration file. If you wish, you may change the driver option to sqlite and it will use the SQLite database included in the app/database directory.
The Laravel PHP artisan serve command helps running applications on the PHP development server. As a developer, you can use Laravel artisan serve to develop and test various functions within the application. It also accepts two additional options. You can use the host for changing application's address and port.
Server RequirementsThe Laravel framework has a few system requirements. You should ensure that your web server has the following minimum PHP version and extensions: PHP >= 8.0. BCMath PHP Extension.
go to the root folder in which laravel is installed using cd command. In the root folder, run the command php artisan in terminal. It should work fine now.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With