Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why should I keep running artisan serve command to keep the server working?

I'm learning laravel, and at the beginning I had run the command

php artisan serve

and keep my terminal window open so I can keep the server running, but later I wanted to just work with my app just like working on a normal php application so I created a virtual host directed to my laravel application "public" folder.

here is the problem:

I still have to run the "php artisan serve" and open my virtual server url

http://brk.localhost:8000

and then close the terminal, all that before I can normally open this link without defining the port number 8000. and If I left my computer and get back to continue work, I found that I can't access it unless I do the whole process again. and If I made a modification to any of the application views I get the same problem.

what am I missing?

like image 924
medo ampir Avatar asked Feb 27 '16 09:02

medo ampir


2 Answers

Just add the and symbol '&' to the end of the command. This will keep it running in the background.

like image 190
Basel J. Hamadeh Avatar answered Sep 20 '22 00:09

Basel J. Hamadeh


There are 3 main ways that you can access your Laravel app while you are developing it.

1) Using artisan serve

This method is probably the easiest method but it does mean that you have to remember to do this every time you start working on your project, which you have said that you do not want to do.

2) Using Laravel Homestead

This method requires a little more configuration but the documentation is very good. You won't have to remember to keep the terminal window open when you use it, but you'll still have to remember to keep the virtual machine running.

3) Set up LAMP / MAMP / WAMP or even LEMP

Setting up a local Apache or Nginx daemon on your own machine will require the most amount of configuration but it will mean that your web server automatically starts with your OS so whatever you put in your web directory will always be accessible through the web browser. You will not need to run and terminal commands or run a virtual machine.

Please note, however, that by using a local Apache/Nginx daemon you will be sacrificing a lot of flexibly and you will not have the luxury of deleting it all and starting again in a few minutes if you mess up the config.

Still, a lot of people still prefer to run their own Apache/Nginx daemon locally for development. I am one of them.

like image 35
Joseph Avatar answered Sep 19 '22 00:09

Joseph