Does "Artisan" need the cmd to remain open?

Asked

Viewed 168 times

-2

When typing the command php artisan server in the folder of the project cmd he returns me the message:

Starting Laravel development server: http://127.0.0.1:8000 

I realize that the web page of larevel opens normally, but the prompt gets stuck "Startando." is normal? I need to keep this prompt open always to run the server?

  • 1

    Yes, it’s normal, my friend

  • OK, thank you very much

  • Not necessarily. You can run the command php artisan serve & exit (on Linux). It will close the terminal and continue running the server.

1 answer

2

Yes, but it could have been "programmed" in different ways, but there the goal is simply to have on the screen log outputs and possible errors already in the interface itself.

Example, I downloaded a project already started in Laravel via git and tried to run, but my local PHP is with some necessary extensions disabled, so I can get the error:

exemplo de erro ao iniciar um projeto Laravel

You could also on your own "direct" the output to another place or force the process to start in the background on Windows running:

start /B php artisan serve

It would have a result like that:

C:\Users\new_g\laravel8>start /B php artisan serve

C:\Users\new_g\laravel8>Starting Laravel development server: http://127.0.0.1:8000
[Sun Jan  3 17:12:01 2021] PHP 8.0.0 Development Server (http://127.0.0.1:8000) started

C:\Users\new_g\laravel8>

Of course a local server program could do this "naturally", but it depends on who developed the program and the intention, there is no reason to do too much in a simple program that simply works by command line, that is with a simple Ctrl+C you can kill the process, thus ending the program.

In the end it all depends on how things are programmed, could someone do something like to start:

c:\projetoX>server start --port 8000
c:\projetoX>server start --port 5000

This way I would start two servers with different ports

And then something like:

c:\projetoX>server stop --port 8000

This would display the server only logs on port 5000:

c:\projetoX>server log --port 5000

And although not "locking the CMD/terminal" yet there would be a process running that the link to facilitate access of the logs or finalize would be the port you point, it all depends on how the developers will create the functioning. Although in the end it doesn’t bring great advantages.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.