When I want to deploy my Laravel 11 project I get an error “can’t read app/Http/Middleware/TrustProxies.php: No such file or directory”.
I use fly.io for the first time. Is this aan Laravel 11 issue or is this an existing issue? What can I do to correct this issue?
Hello @mjhcremer! Welcome to Fly.io!
This is an existing issue where the Dockerfile generated during fly launch
does not accommodate the new syntax in setting trusted proxies for a Laravel 11 project.
A fix has already been provided for this, but will only be rolled out once the next official version is released for flyctl
.
In the meantime, you can do one of three things:
- Update the Dockerfile generated in your project to use the latest syntax for setting Trusted Proxies.
- Install the pre-release version which contains changes that accommodates the latest version. Rerun
fly launch
to generate the proper Dockerfile for your project.
- The pre-release version makes use of a new package dockerfile-laravel which was made specifically to handle generating prod-ready or local-ready(please pass --dev for local) Dockerfiles for Laravel applications. You can install this via
composer require fly-apps/dockerfile-laravel
, and run its command to replace the Dockerfile generated for your app: vendor/bin/dockerfile-laravel generate
. This should see that your Laravel project’s under the latest 11 version, and properly set the correct syntax for trusting proxies in the Dockerfile it generates.
Once your Dockerfile has been updated with the proper syntax for trusting proxies, do a fly deploy
to send your changes to your Laravel Fly app. And that should fix the issue you’ve encountered.
1 Like