How to deploy your Laravel app in under five minutes

The Laravel team at Fly.io has made a package that enables you to deploy your Laravel app in under five minutes! It’s called fly-laravel and it can set up your Laravel app, MySQL and/or Redis, and can even set up Cron and queues for you. It’ll also handle some behind-the-scenes stuff to get everything linked up, like sharing credentials (safely!) and setting hostnames. And to make it even better, running your app probably won’t cost you anything!

This is the free allowance that you receive with every plan on Fly.io:

  • Up to 3 VMs (shared CPU, 256 MB)
  • 3GB persistent volume storage
  • 160 GB outbound data transfer

Get your app up and running, in under 5 minutes!

Prerequisites:

  • You have an account on Fly.io
  • You have created an organization on Fly.io
  • You have installed the flyctl agent

Deploy your app:

  1. Install the fly-laravel package: composer require fly-apps/fly-laravel
  2. Launch the Laravel app: vendor/bin/fly-laravel launch
  3. Launch the MySQL app: vendor/bin/mysql launch:mysql
  4. Deploy the MySQL app: answer yes on the prompt during launch, or run vendor/bin/fly-laravel deploy:mysql
  5. Deploy the Laravel app: vendor/bin/fly-laravel deploy
  6. Run the migrations: flyctl ssh console (this will connect to the shell of the Laravel app) followed by php artisan migrate

If you’re anything like me you are a lazy slob like to make your life easier. If you add alias fly-laravel=vendor/bin/fly-laravel to your .zshrc or .bashrc file, you can type fly-laravel instead of vendor/bin/fly-laravel for every command.

What about Redis?

Redis can be set up the exact same way like MySQL, using the fly-laravel launch:redis and fly-laravel deploy:redis command. More info on Github: GitHub - fly-apps/fly-laravel: Run your Laravel apps on Fly

Launching AND Deploying???

Launching an app means creating it in your organization on Fly.io. This sets up an app’s environment and configuration. Once an app has been launched, you can deploy your code every time you want the latest changes to take effect. Launching is done once to create the app, deploying is done every time you want to update its code.

More information

You can find the full documentation of the package on Github: GitHub - fly-apps/fly-laravel: Run your Laravel apps on Fly

The fly-laravel package is still in beta and could still have issues. Please create a Github Issue if you find a bug!

Exceeding the free allowance on Fly.io will cost money. The fly-laravel package will provision the smallest machine to stay within the free allowance, but it’s up to you to double-check!

Please let me know what you think, if there are any issues or if something isn’t completely clear to you!

7 Likes