Laravel php artisan serve to mimic HTTPS

30,286

Solution 1

You can use ngrok for that

php artisan serve
cd <path-to-ngrok>
./ngrok http localhost:8000

https://ngrok.com/

Solution 2

Laravel uses the in-built PHP5.4 development server php -S (http://php.net/manual/en/features.commandline.webserver.php) for it's artisan serve command (see Illuminate\Foundation\Console\ServeCommand). This only supports plain HTTP, so no, this isn't possible. Your best bet would be to use a Vagrant box set up to work with SSL/TLS.

Share:
30,286

Related videos on Youtube

Jazzy
Author by

Jazzy

Updated on July 09, 2022

Comments

  • Jazzy
    Jazzy almost 2 years

    I have been searching around to see if there is a way I can mock SSL for local development using Laravel's artisan to serve HTTPS with no luck.

    Is this possible and if so, how?

    I understand this is a very general question, but I am not seeing anything on this in searches.

  • IceFire
    IceFire over 3 years
    Question was explicit about artisan serve
  • Matthew Setter
    Matthew Setter about 3 years
    This does not answer the question. It facilitates connections from outside the local network, via ngrok, to the locally running web server, but only on HTTP, not HTTPS.
  • Phạm Huy Phát
    Phạm Huy Phát over 2 years
    @MatthewSetter this does answer the question. when you call ./ngrok http [PORT] it will create an https proxy to the http version. You can see in the terminal logs something like: d16f-2402-800-631d-928e-dc2b-9136-ad8a-bd9f.ngrok.io -> localhost:80 go to the link with https and the secure logic should be applied
  • Matthew Setter
    Matthew Setter over 2 years
    Fair point, @PhạmHuyPhát. Happy to admit I was wrong: ngrok.com/docs#tls. That said, the second line's not required if ngrok's installed in the user's path.
  • Phạm Huy Phát
    Phạm Huy Phát over 2 years
    vagrant approach might be too expensive for development feature