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
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.
Related videos on Youtube
Author by
Jazzy
Updated on July 09, 2022Comments
-
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.
-
Vladimir Vukanac almost 6 yearsIf you are maybe a Mac user
valet
may help you laravel.com/docs/5.6/valet#securing-sites
-
-
IceFire over 3 yearsQuestion was explicit about artisan serve
-
Matthew Setter about 3 yearsThis 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 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 over 2 yearsFair 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 over 2 yearsvagrant approach might be too expensive for development feature