Posts Learn Components Snippets Categories Tags Tools About
/

How to set port number in Laravel Serve Command

Get to know How to set port number in Laravel Serve Command the easy and straight forward way

Created on Jul 27, 2022

385 views

Running "php artisan serve" by default will launch a local PHP server on port 8000. But in the case you want a different port, you can specify the "--port" flag.
php artisan serve // default port 8000
php artisan serve --port=8080 // now port 8080
The command above will output the following.
Starting Laravel development server: http://127.0.0.1:8080
[Tue Jul 26 23:47:11 2022] PHP 8.1.4 Development Server (http://127.0.0.1:8080) started

How to know artisan serve options


To get all of the options from "php artisan serve" you can make use the "help" command.
php artisan help serve
The command above will output the following options.
Description:
  Serve the application on the PHP development server

Usage:
  serve [options]

Options:
      --host[=HOST]     The host address to serve the application on [default: "127.0.0.1"]
      --port[=PORT]     The port to serve the application on
      --tries[=TRIES]   The max number of ports to attempt to serve from [default: 10]
      --no-reload       Do not reload the development server on .env file changes
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)