Laravel is one of the most popular web frameworks for PHP and for good reason. It comes bundled with most common web app needs, including authentication, authorization, localization, and support for multiple database backends including PostgreSQL.
Lets get started!
Create a new PostgreSQL database on Render and copy the internal DB URL to use below.
Fork hoangsvit/laravel-10x-docker and create a new Web Service on Render, giving Render permission to access your forked repo.
Docker for the runtime, and add the following environment variables under the Advanced section:
||The internal database URL for the database you created above.|
||Copy the output of
Thats it! Your Laravel web app will be live on your Render URL as soon as the build finishes. You can test it out by registering and logging in.
The commit history of our sample repo is useful in understanding the modifications needed for an existing Laravel app.
If you havent already, make sure to run
php artisan make:auth to generate authentication scaffolding for your app.
Force HTTPS on all assets served by Laravel to avoid mixed content warnings in the browser. Render already manages and terminates TLS certificates for you, but Laravels asset helper needs to be configured to serve everything over TLS. You can do this by following the changes in Force HTTPS for Laravel.
Finally, add a deploy script that will be run when your PHP app starts up.
You should now be able to deploy your existing Laravel app on Render.