Support the ongoing development of Laravel.io →
posted 3 years ago
Last updated 1 year ago.
0

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.

0

If you working on windows box, maybe you can try Laragon, it has SSL support for development purpose https://laragon.org/docs/easy-to-use.html

0

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.

0

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: https://imgur.com/a/EkolMbz

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

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.