masatar
masatar

Reputation: 88

Difference between 'php artisan serve' and 'php -S localhost:8000 -t public'?

I want to run my laravel5 project with

php artisan serve

but i got an empty page. Then I tried with

php -S localhost:8000 -t public

and it worked.

The strange thing is, the first command worked for me at the beginning and now it doesnt.

I also tried to call in my browser:

http://localhost/myProject/public/ 

In this case, its worked but without loading my css files.

Can someone explain me what the difference is between these commands and why the first one not working for me anymore?

Upvotes: 0

Views: 2309

Answers (1)

Shiro
Shiro

Reputation: 7554

The best way to understand Laravel Coding is read the Code itself.

You can refer to vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php

And the command actually call to this.

/** * Get the full server command. * * @return string */ protected function serverCommand() { return sprintf('%s -S %s:%s %s/server.php', ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)), $this->host(), $this->port(), ProcessUtils::escapeArgument($this->laravel->basePath()) ); }

What you asking what is the different. The different is php artisan serve specific add the /server.php in the argument and php -S does not include that.

Upvotes: 1

Related Questions