1

I installed a new Laravel instance, using version 5.8. Along the way, I found out that I can't serve the project using the normal Laravel php artisan serve command.

After some research with lots of trial and error, I came across this answer on StackOverflow that helped me with this method php -S localhost:8000 -t public/ with which I followed to change the port to port 9000, and it served the project perfectly.

Now my question is how can I go about getting the artisan command to be the default command to serve and rum my Laravel 5.8 on Windows just like before? I don't know anything about configuring Laravel core commands.

3
  • What error do you get after you type in php artisan serve ? Commented Mar 21, 2019 at 22:15
  • The port error is a little weird because one of the features of the 5.8 version in case of a port conflict is to try a different port from 8000 up to 8009. So, at least you have those ports full the problem must be somewhere else. Please, use the -vvv option and provide the error you get. Commented Mar 21, 2019 at 22:22
  • Watch your terminal output after you try to access localhost:8000. Maybe the problem is in your PHP configuration. When you use php -S localhost:8000 -t public/ it is your PHP built-in server. Commented Mar 21, 2019 at 23:21

3 Answers 3

4

I tried this command.

php -S  127.0.0.1:9000 -t public/

after running this its works fine.

and also php artisan serve command works fine.

hope it will help.

Sign up to request clarification or add additional context in comments.

Comments

2

You should open ServeCommand.php file (Illuminate\Console) and then change getOptions method

protected function getOptions()
{
    $host = env('SERVE_HOST', '127.0.0.1');  
    $port = env('SERVE_PORT', 8080);

    return [
        ['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', $host],
        ['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', $port],
    ];
}

when create a SERVE_HOST and SERVE_PORT in your .env file

SERVE_HOST=localhost
SERVE_PORT=9000

source

1 Comment

Don't change vendor files, the changes may be overwritten by composer. Instead, inherit your own command from it, override said method and register it (if not done automatically). It will replace the default one.
0

You can run the project on port 80. If you are using Linux simply run the command from the embedded server with root user permission.

Example: sudo php -S localhost: 80 -t public /

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.