Repository navigation
Conversation
Laravel compiles Blade views on the first requests of every new Lambda instance, in /tmp. `php artisan view:cache` before deploying skips that, now that laravel-bridge reads compiled views from the package (brefphp/laravel-bridge#217): - zip: `relative_hash` in config/view.php (Laravel 9+, every supported version) so that the compiled file names match on Lambda, and `storage/framework/views/*.php` added to the package, - container images: `view:cache` in the Dockerfile, where the application is in /var/task. Validated on Lambda (zip compiled on macOS with relative_hash, image built with the Dockerfile above): compiled views read from /var/task, `Blade::render()` and inline components still compile in /tmp. Without the laravel-bridge fix, the compiled views are ignored and nothing breaks. Claude-Session: https://claude.ai/code/session_01Gw1bKZVqSMqFbcwXuPvUDL
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents compiling Blade views before deploying a Laravel application (
php artisan view:cache), in a new "Compiling views before deploying" section of the Laravel getting started page. Without it, each new Lambda instance compiles the views again on its first requests.It relies on brefphp/laravel-bridge#217, which makes the bridge read the compiled views from the package. Before that release, following these docs changes nothing: the views keep compiling in
/tmp, as today.view.relative_hash(Laravel 9 and later, so every Laravel version the bridge supports), because compiled file names depend on the absolute path of each view. Runview:cachebefore every deployment, and addstorage/framework/views/*.phpto theserverless.ymlpatterns.view:cachein theDockerfile. The application is at/var/taskthere, sorelative_hashisn't needed.php artisan optimizeis still discouraged because it caches the configuration.Both recipes were followed literally on AWS Lambda, with the bridge from brefphp/laravel-bridge#217 and a Laravel 13 application, FPM and Octane: the zip compiled on macOS, the container image built from the documented
Dockerfile. On both:/var/task/storage/framework/views, despite the 1980 file dates in the zip;Blade::render(), inline components) still compile in/tmp.