Your Laravel can run directly on Lambda with AWS Lambda Web Adapter
This is the code used for Laravel on Lambda with Snapstart.
To build and deploy this stack, please have the following tools installed.
- Docker
- Node.js
- AWS CLI
- AWS CDK
You also need a DNS domain hosted on Route53.
Set up your .env file.
$ cd src/laravel
$ cp .env.example .env
$ composer install --prefer-dist --optimize-autoloader --no-interaction
$ php artisan key:generateUse S3 as Filesystem:
FILESYSTEM_DISK=s3Use stdout as Log:
LOG_CHANNEL=stdoutEdit config/logging.php -> channels
'channels' => [
// ...
'stdout' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stdout',
],
'formatter' => env('LOG_STDOUT_FORMATTER'),
],
// ...
]Use redis as Cache and Session driver:
CACHE_DRIVER=redis
SESSION_DRIVER=redis
REDIS_PORT=6379This stack use .env file to provide configuration values.
Copy cdk/.env.example to cdk/.env and update the values to fit your needs.
Then install CDK dependencies
cd cdk
# Please follow the example to configure
cp .env.example .env
npm installPreview the changes
make diffDeploy the stack
make deployWhen the deployment is done, open ROUTE53_SITENAME to view the home page.
Run the following command to delete ALL the resources deployed for this project, including the database, redis cluster and S3 bucket.
make destroySee CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.