
Prepare a Laravel app
Bring your own Laravel app, or create a new one! If you want to start fresh, hereās how to set up a new application. Youāll need PHP 8+ and composer installed locally. You can check your PHP version usingphp --version.
http://localhost:8000 and see the home page.
Deploy to Fly.io
Install Fly
First, install flyctl, the Fly.io CLI, and sign up to Fly.io if you havenāt already.Launch
Next, weāll use thelaunch command to automagically configure your app for Fly and deploy it to the Fly cloud. This will add a few files to your code baseābut, donāt worry, it will ask before overwriting anything.
If you havenāt already, go ahead and run fly launch!
Launch Configuration
Once you accept the configuration, this would proceed with adding default secrets, deploying the accepted extensions, and generating files on your project:.github/workflows/fly-deploy.yml,fly.toml- Configurations specific to hosting on Fly- .fly directory - A directory containing configuration files for running Nginx/PHP in a container
- Dockerfile - Used to build a container image that is run in fly
- .dockerignore - Used to ensure certain files donāt make its way into your image
Success!
You should be able to visithttps://your-app-name.fly.dev and see the Laravel demo home page.
Thatās it! Run fly apps open to see your deployed app in action.
Try a few other commands:
fly logs- Tail your application logsfly status- View your appās current deployment statusfly ssh console- Open a terminal on your VMfly deploy- Deploy the application after making changes
Customizing your app
If you have other environment variables to set, you can edit thefly.toml file and add them.
"https://<your-app-name>.fly.dev").
For sensitive data, you can set secrets with the fly secrets set command:
Deploy
Once youāve made changes for your app locally, you can runfly deploy to deploy your changes.
Some Notes
Runningfly launch (and later fly deploy) uses the Dockerfile to build a container image, copying your application files into the resulting image.
Fly doesnāt care about the state of your git repository - it copies whatever files are present (except for files ignored by .dockerignore).