Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alain.duchesneau's avatar

Automatically open Chrome after php artisan serve, one line

Hi, Just sharing a tiny tip today. (On macOS) In my ~/.bash_profile, I added the following line:

alias pas='php ./artisan serve & open -b com.google.Chrome http://127.0.0.1:8000'

Save the file, open a new terminal session.

So whenever I want to serve my project AND open it in my browser, I only have to type pas (for PHP Artisan Serve, of course)

0 likes
3 replies
alain.duchesneau's avatar

Well, it looks like it's not a good idea. There are situations where the artisan serve continue to run even thought the process is stopped, when it's not in reality.

I don't recommend.

finder2's avatar

Is there some equal posibility on windows?

tobiasj's avatar

@finder2 yes there is. As for starting chrome from commandline: start chrome "http://127.0.0.1:8000"

As for creating alias I'd recommend using either windows built-in powershell (which I did not test, but I heard that it comes with features like alias) or "Cmder" (just google it).

Note: there are alternative ways to create "alias-like" commands, but I find them pretty anoying to create (called Doskey Macros), so I'd just go with either powershell or Cmder. With Cmder you get some good features as well, like working coloring with phpunit, git integration and more.

I just whipped up a little snippet/guide you can follow to do the same with Cmder here: https://bitbucket.org/snippets/tobiasjakob/bAzye

Please or to participate in this conversation.