BlogLaravel. How to Use the Integrated Web Server for Local DevelopmentIf you want to develop on your computer before you deploy to a real server, Laravel can help. The artisan serve command will spin up a local server, which you can use for quick preview or full fledged development. To quickly run it you type in your terminal:
You will now see a confirmation message by Laravel telling you that the server is running.
Point your browser to the following address 127.0.0.1:8000 and you will see your Laravel application running. Advanced UsageHowever working with IPs and ports may not be the ideal solution in some cases. For instance when working with remote services and a domain name is required. Here is how to start a local server with a domain name and no port. Lets say I want to develop locally on dev.mywebsite.com instead of 127.0.0.1:8000 Step 1. Put a New Entry in your Host FileOpen your host file and put a new line in:
This will tell your machine, that the development website is located on your computer. Test its pointed correctly by pinging the domain
2. Launch the Artisan Serve Command with Custom ParametersTo force artisan to server the application on custom domain name and port we will use the --host and --port parameters.
The above command will tell artisan to launch the server with our domain name and listen on port 80. You should see a confirmation message by Laravel.
Point your browser to the following address dev.mywebsite.com and you will see your Laravel application running. Now you may start working on your application on your computer usng a nice development domain name, test your code locally befor deploying to a live server.
|