Running (and Stopping) a Web Server with Symfony on Windows

Once you have your web application created in Symfony, it isn’t long before you learn you can run a server from the command line – that’s right, no need to install Apache, NGINX, Wamp, Xammp etc. etc. Let’s start up that server right away.

Run a command shell:

Go the root of your application:

Run the server:

As you can see, Windows needs a nudge to tell it to use PHP by default. You will now see something similar to:

Symfony server

That shows you which port to connect to – very useful!

To end the server, whilst the command window is selected:

Easy enough, right?

If like me, though, you have a habit of running Windows Powershell ISE as your shell, you need to be careful because the server doesn’t play nicely in this situation and you will find you can’t end the server with control-c. In fact, even if you close PowerShell, that pesky server will continue running. If you find yourself in this situation, there is of course the “reboot” method, but if you don’t fancy that, you can use Task manager to end it for you:

Do that for any others that you find, depending on how many times you ran the server.

Can’t see PHP or are unable to work out which process has opened the port? This really shouldn’t happen but there is a command in Windows which can show you which process has which port open.

Go back to the command shell:

List the open ports:

Zip through there looking for anything mentioning your port. So for example, let’s imagine we opened the server on port 8001:

That final column is the process ID. Now head back to the task manager:

 

twittergoogle_plusredditpinteresttumblrmail

Written by Stephen Moon
email: stephen at logicalmoon.com
www: https://www.logicalmoon.com


Hey! Did you enjoy reading this? If you did and would like an email when I add new content, just subscribe to my list. You can unsubscribe at any time.


Leave a Reply

Your email address will not be published. Required fields are marked *