Support the ongoing development of →
posted 2 years ago
Last updated 10 months ago.

The php artisan serve command just serves via. PHP itself, which does not support SSL from my understanding.

If you need HTTPS, you will need a webserver such as NGINX or Apache and configure it to use SSL.

If you're working locally, there are a ton of pre-built tools to support this depending on what system you're using.


If you working on windows box, maybe you can try Laragon, it has SSL support for development purpose


What OS you are working on.

If you are on windows, you can start with Laragon. On linux and Mac OS, you can use Laravel valet.


First, declare a variable in the .env file called ENFORCE_SSL and assign it a boolean value so whenever you assign it the value true, all links or URLs of your project will be redirected to HTTPS protocol and you don’t have to manually go and change all of your links to HTTPS, Laravel will take care of that itself. So to recap,

Go to your .env file and add this ENFORCE_SSL = false Go to AppServiceProvider and add this at the top use Illuminate\Contracts\Routing\UrlGenerator; Add code below to boot method of AppServiceProvider class, you can use the env helper function to read any variable from the .env file i.e env(‘ENFORCE_SSL’, false). The second parameter is the default value if that variable is not found.

Here is the sample code:

You can change the value of ENFORCE_SSL to true anywhere you need to enforce HTTPS in Laravel.

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.