Whats the point of running Laravel with the command 'php artisan serve'?

前端 未结 4 1039
广开言路
广开言路 2020-12-14 16:23

I dont seem to understand why we need to run a Laravel app with php artisan serve vs just running it with Apache or nginx. I k

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 16:36

    One advantage of using php artisan serve over a typical webserver during development is you can use Psysh as a debugger (Laravel Tinker) to set a breakpoint.

    For example, at the line of code I want to break at I type:

    eval(\Psy\sh());
    

    Then I hit the page that will run that section of code and when it gets to that line it will break into a Psy Shell repl (in the commandline window where I started php artisan serve). Then I can inspect variables, etc. at that point of execution. It's very useful for debugging. As far as I know, you can't do this running Apache/Nginx. It has to be with artisan serve (or running automated tests).

    More info here:

    https://tighten.co/blog/supercharge-your-laravel-tinker-workflow

    http://psysh.org/

提交回复
热议问题