Laravel/Livewire File Upload Stopped Working #1435
-
This isn't a Bref issue, per se, but the issue only occurs when deployed on Bref, and it is most likely a misconfiguration in my I recently updated to Laravel 10, and everything is working locally, but one page is broken when deployed via Bref. I think the issue is that Laravel's Relevant portion of the stack trace is:
Clearly Livewire is trying to write to The helper Again, this was all working before upgrading from Laravel 9 to 10 (which required many dependencies to also be upgraded), which makes me think that some dependency code changed, but it's also possible this is a configuration change error. I'm pretty sure I could fix this by setting Based off of light searching, it seems like the only way to do this is via code, (e.g. editing Any advice is welcome. Here's my `serverless.yml` file. Lighted edited for clarityservice: laravel
params:
default:
app_debug: true
app_env: dev
app_key: ${ssm:/laravel/app_key}
app_name: APP
app_storage: /tmp
aws_access_key_id: ${ssm:/laravel/aws_access_key_id}
aws_endpoint: https://s3.us-east-2.amazonaws.com
aws_public_endpoint: https://s3.amazonaws.com
aws_secret_access_key: ${ssm:/laravel/aws_secret_access_key}
broadcast_driver: log
certificate_arn: ${ssm:/laravel/certificate_arn}
db_connection: mysql
db_database: app
db_host: ${ssm:/laravel/db_host}
db_password: ${ssm:/laravel/db_pwd}
db_port: ${ssm:/laravel/db_port}
db_username: app
livewire_manifest_path: /tmp/storage/livewire-compoonents.php
view_compiled_path: /tmp/storage/framework/views
log_channel: stderr
log_level: debug
mail_from_name: ${param:app_name}
mail_host: mailhog
mail_mailer: smtp
mail_port: 1025
private_route_table_1a_id: ${ssm:/laravel/private_route_table_1a_id}
private_subnet_1a_id: ${ssm:/laravel/private_subnet_1a_id}
private_subnet_1b_id: ${ssm:/laravel/private_subnet_1b_id}
public_route_table_id: ${ssm:/laravel/public_route_table_id}
public_subnet_1a_id: ${ssm:/laravel/public_subnet_1a_id}
queue_connection: sync
session_cookie: my_app_session
session_lifetime: 120
session_secure_cookies: true
vpc_id: ${ssm:/laravel/vpc_id}
dev:
asset_bucket_name: dev.assets.app.net
app_debug: false
domain: dev.my.app.net
profile: terraform-dev
aws_public_bucket: app-dev-public-my
aws_public_url: https://12345asdf.cloudfront.net
prod:
app_env: production
asset_bucket_name: assets.app.net
cache_instance_size: cache.t3.small
domain: my.app.net
app_debug: false
profile: terraform-prod
aws_public_bucket: app-prod-my-public
aws_public_url: https://cdn.app.net
stage:
app_env: stage
asset_bucket_name: stage.assets.app.net
domain: stage.my.app.net
profile: terraform-stage
provider:
name: aws
profile: ${param:profile}
region: us-east-2
stage: ${opt:stage, 'stage'}
runtime: provided.al2
apiGateway:
shouldStartNameWithService: true
environment:
APP_DEBUG: ${param:app_debug}
APP_ENV: ${param:app_env}
APP_KEY: ${param:app_key}
APP_NAME: ${param:app_name}
APP_STORAGE: ${param:app_storage}
APP_URL: https://${param:domain}
ASSET_URL: https://${param:domain}
LIVEWIRE_ASSET_URL: https://${param:domain}
LOG_CHANNEL: ${param:log_channel}
LOG_LEVEL: ${param:log_level}
QUEUE_CONNECTION: ${param:queue_connection}
SERVER_SOFTWARE: bref
TELESCOPE_ENABLED: false
# DB
DB_CONNECTION: ${param:db_connection}
DB_DATABASE: ${param:db_database}
DB_HOST: ${param:db_host}
DB_PASSWORD: ${param:db_password}
DB_PORT: ${param:db_port}
DB_USERNAME: ${param:db_username}
# Drivers
BROADCAST_DRIVER: ${param:broadcast_driver}
CACHE_DRIVER: ${param:cache_driver}
SCOUT_DRIVER: ${param:scout_driver}
# Filesystem paths
FILESYSTEM_DISK: public
LIVEWIRE_MANIFEST_PATH: ${param:livewire_manifest_path}
VIEW_COMPILED_PATH: ${param:view_compiled_path}
# Third-party Integration keys and settings:
# AWS S3
# AWS_DEFAULT_REGION: ${param:aws_default_region}
AWS_ENDPOINT: ${param:aws_endpoint}
# Public AWS S3
AWS_PUBLIC_ACCESS_KEY_ID: ${param:aws_access_key_id}
AWS_PUBLIC_BUCKET: ${param:aws_public_bucket}
AWS_PUBLIC_ENDPOINT: ${param:aws_public_endpoint}
AWS_PUBLIC_SECRET_ACCESS_KEY: ${param:aws_secret_access_key}
AWS_PUBLIC_URL: ${param:aws_public_url}
package:
# Directories to exclude from deployment
patterns:
- '!.env'
- '!node_modules/**'
- '!public/storage'
- '!resources/assets/**'
- '!storage/**'
- '!tests/**'
- '!vendor/laravel/dusk/bin/**'
- '!vendor/**/docs/**'
- '!vendor/**/tests/**'
functions:
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-81-fpm}
- ${bref-extra:redis-php-81}
events:
- httpApi: '*'
vpc:
securityGroupIds:
- !GetAtt ServerlessSecurityGroup.GroupId
- ${ssm:/laravel/mysql_security_group_id}
subnetIds:
- ${param:private_subnet_1a_id}
- ${param:private_subnet_1b_id}
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-81} # PHP
- ${bref-extra:redis-php-81}
- ${bref:layer.console} # The "console" layer
vpc:
securityGroupIds:
- !GetAtt ServerlessSecurityGroup.GroupId
- ${ssm:/laravel/mysql_security_group_id}
subnetIds:
- ${param:private_subnet_1a_id}
- ${param:private_subnet_1b_id}
cron:
handler: artisan
layers:
- ${bref:layer.php-81} # PHP
- ${bref-extra:redis-php-81}
- ${bref:layer.console} # The "console" layer
vpc:
securityGroupIds:
- !GetAtt ServerlessSecurityGroup.GroupId
- ${ssm:/laravel/mysql_security_group_id}
subnetIds:
- ${param:private_subnet_1a_id}
- ${param:private_subnet_1b_id}
plugins:
- ./vendor/bref/bref
- ./vendor/bref/extra-php-extensions
- serverless-lift
resources:
Resources:
SubnetRouteTableAssociationLambdaPrivateA:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: ${param:private_subnet_1a_id}
RouteTableId: ${param:private_route_table_1a_id}
SubnetRouteTableAssociationLambdaPublicA:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: ${param:public_subnet_1a_id}
RouteTableId: ${param:public_route_table_id}
ServerlessSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SecurityGroup for Serverless Functions
VpcId: ${param:vpc_id}
constructs:
website:
type: server-side-website
assets:
'/css/*': public/css
'/img/*': public/img
'/js/*': public/js
'/vendor/*': public/vendor
'/favicon.ico': public/favicon.ico
'/mix-manifest.json': public/mix-manifest.json
'/robots.txt': public/favicon.ico
certificate: ${param:certificate_arn}
domain: ${param:domain}
forwardedHeaders:
- Accept
- Accept-Language
- Content-Type
- Origin
- Referer
- User-Agent
- X-Forwarded-Host
- X-Requested-With
- X-Csrf-Token
- X-Livewire |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Ugh. OK, I figured it out. I have a custom service provider that's very obviously designed to help with Bref. <?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ServerlessStorageServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// if (in_array(config('server_software'), ['bref', 'vapor'])) {
if (in_array(env('SERVER_SOFTWARE'), ['bref', 'vapor'])) {
$path = '/tmp/storage';
$directories = [
'/app',
'/cache',
'/framework/cache',
'/framework/views',
'/bootstrap/cache',
];
foreach ($directories as $directory) {
if (! is_dir($path.$directory)) {
mkdir($path.$directory, 0755, true);
}
}
$this->app->useStoragePath($path);
}
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
} I recently was using a linter to try to format my code nicely, and it complained about using Still, this service provider might be something worth mentioning in Bref's Laravel docs, since I'm pretty sure this is non-obvious. Happy to take a crack at it if anyone thinks it's useful. |
Beta Was this translation helpful? Give feedback.
Ugh. OK, I figured it out.
I have a custom service provider that's very obviously designed to help with Bref.
ServerlessStorageServceProvider
.