简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM