├── tmp └── .gitkeep ├── src ├── laravel │ ├── public │ │ ├── favicon.ico │ │ ├── robots.txt │ │ ├── .htaccess │ │ └── index.php │ ├── resources │ │ ├── css │ │ │ └── app.css │ │ ├── js │ │ │ ├── app.js │ │ │ └── bootstrap.js │ │ └── views │ │ │ └── welcome.blade.php │ ├── database │ │ ├── .gitignore │ │ ├── seeders │ │ │ └── DatabaseSeeder.php │ │ ├── migrations │ │ │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ │ │ ├── 2014_10_12_000000_create_users_table.php │ │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ │ └── 2019_12_14_000001_create_personal_access_tokens_table.php │ │ └── factories │ │ │ └── UserFactory.php │ ├── storage │ │ ├── logs │ │ │ └── .gitignore │ │ ├── app │ │ │ ├── public │ │ │ │ └── .gitignore │ │ │ └── .gitignore │ │ └── framework │ │ │ ├── views │ │ │ └── .gitignore │ │ │ ├── cache │ │ │ ├── data │ │ │ │ └── .gitignore │ │ │ └── .gitignore │ │ │ ├── sessions │ │ │ └── .gitignore │ │ │ ├── testing │ │ │ └── .gitignore │ │ │ └── .gitignore │ ├── bootstrap │ │ ├── cache │ │ │ └── .gitignore │ │ └── app.php │ ├── tests │ │ ├── TestCase.php │ │ ├── Unit │ │ │ └── ExampleTest.php │ │ ├── Feature │ │ │ └── ExampleTest.php │ │ └── CreatesApplication.php │ ├── .gitattributes │ ├── package.json │ ├── vite.config.js │ ├── .gitignore │ ├── .editorconfig │ ├── app │ │ ├── Http │ │ │ ├── Controllers │ │ │ │ └── Controller.php │ │ │ ├── Middleware │ │ │ │ ├── EncryptCookies.php │ │ │ │ ├── VerifyCsrfToken.php │ │ │ │ ├── PreventRequestsDuringMaintenance.php │ │ │ │ ├── TrimStrings.php │ │ │ │ ├── TrustHosts.php │ │ │ │ ├── Authenticate.php │ │ │ │ ├── ValidateSignature.php │ │ │ │ ├── TrustProxies.php │ │ │ │ └── RedirectIfAuthenticated.php │ │ │ └── Kernel.php │ │ ├── Lib │ │ │ └── Helper.php │ │ ├── Providers │ │ │ ├── BroadcastServiceProvider.php │ │ │ ├── AppServiceProvider.php │ │ │ ├── AuthServiceProvider.php │ │ │ ├── EventServiceProvider.php │ │ │ └── RouteServiceProvider.php │ │ ├── Console │ │ │ └── Kernel.php │ │ ├── Jobs │ │ │ └── LatencyTest.php │ │ ├── Exceptions │ │ │ └── Handler.php │ │ └── Models │ │ │ └── User.php │ ├── routes │ │ ├── channels.php │ │ ├── api.php │ │ ├── console.php │ │ └── web.php │ ├── config │ │ ├── cors.php │ │ ├── services.php │ │ ├── view.php │ │ ├── hashing.php │ │ ├── broadcasting.php │ │ ├── sanctum.php │ │ ├── filesystems.php │ │ ├── cache.php │ │ ├── queue.php │ │ ├── mail.php │ │ ├── auth.php │ │ ├── logging.php │ │ ├── database.php │ │ ├── app.php │ │ └── session.php │ ├── phpunit.xml │ ├── .env.example │ ├── artisan │ ├── composer.json │ ├── docker-compose.yml │ └── README.md └── runtime │ ├── bootstrap_dev │ ├── bootstrap │ ├── preload.php │ ├── nginx.conf │ └── php-fpm.conf ├── NOTICE ├── cdk ├── .npmignore ├── .gitignore ├── jest.config.js ├── bin │ └── cdk.ts ├── README.md ├── .env.example ├── test │ └── cdk.test.ts ├── package.json ├── tsconfig.json ├── cdk.json ├── Makefile └── lib │ └── laravel-stack.ts ├── .gitignore ├── Makefile ├── CODE_OF_CONDUCT.md ├── layer.Dockerfile ├── docker-compose.yml ├── README.md ├── CONTRIBUTING.md └── LICENSE /tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/laravel/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/laravel/resources/css/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/laravel/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /src/laravel/resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /src/laravel/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /src/laravel/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /src/laravel/web/app/themes/* 2 | cdk/cdk.out 3 | tmp/*/ 4 | .idea 5 | /cdk/layer/ 6 | .env 7 | compsoer.lock 8 | /src/laravel/composer.lock 9 | -------------------------------------------------------------------------------- /cdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | 10 | cdk.context.json 11 | /.aws-composer/ 12 | -------------------------------------------------------------------------------- /cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /src/laravel/storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | dev: 2 | docker compose up build 3 | docker compose up mysql redis web 4 | docker compose down 5 | 6 | clean: 7 | rm -rf src/laravel/composer.lock 8 | rm -rf src/laravel/vendor 9 | rm -rf tmp/*/ 10 | -------------------------------------------------------------------------------- /src/runtime/bootstrap_dev: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Fail on error 4 | set -e 5 | 6 | if [ ! -d '/tmp/session' ]; then 7 | mkdir -p /tmp/session 8 | fi 9 | 10 | cd /var/task 11 | 12 | /opt/php/bin/php artisan serve --host=0.0.0.0 13 | -------------------------------------------------------------------------------- /src/laravel/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/laravel/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /src/laravel/app/Lib/Helper.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import {LaravelStack} from '../lib/laravel-stack'; 5 | 6 | const app = new cdk.App(); 7 | 8 | const env_development = { 9 | account: process.env.CDK_DEFAULT_ACCOUNT, 10 | region: process.env.CDK_DEFAULT_REGION, 11 | }; 12 | 13 | const appName = process.env.APP_NAME || 'LaravelDemo' 14 | 15 | new LaravelStack(app, appName, {env: env_development}); 16 | -------------------------------------------------------------------------------- /src/laravel/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/laravel/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /src/laravel/tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/laravel/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cdk/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project! 2 | 3 | This is a blank project for TypeScript development with CDK. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `cdk deploy` deploy this stack to your default AWS account/region 13 | * `cdk diff` compare deployed stack with current state 14 | * `cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /cdk/.env.example: -------------------------------------------------------------------------------- 1 | # App Name 2 | APP_NAME=LaravelDemo 3 | 4 | # a DNS domain hosted on Route53 5 | ROUTE53_HOSTEDZONE=example.com 6 | 7 | # the name for your site 8 | ROUTE53_SITENAME=site.example.com 9 | 10 | # database user name. Password is generated automatically and stored in Secret Manager. 11 | DB_USER=admin 12 | 13 | # readiness check path used by Lambda Adapter 14 | READINESS_CHECK_PATH=/ 15 | 16 | # Lambda Adapter log level. Set to 'debug' for troubleshooting 17 | RUST_LOG=info 18 | 19 | # Disable Opcache Preload 20 | PRELOAD_DISABLE=false 21 | 22 | # Enable Snapstart 23 | SNAPSTART_ENABLE=true 24 | -------------------------------------------------------------------------------- /src/laravel/database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | // \App\Models\User::factory()->create([ 18 | // 'name' => 'Test User', 19 | // 'email' => 'test@example.com', 20 | // ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cdk/test/cdk.test.ts: -------------------------------------------------------------------------------- 1 | // import * as cdk from 'aws-cdk-lib'; 2 | // import { Template } from 'aws-cdk-lib/assertions'; 3 | // import * as Cdk from '../lib/cdk-stack'; 4 | 5 | // example test. To run these tests, uncomment this file along with the 6 | // example resource in lib/cdk-stack.ts 7 | test('SQS Queue Created', () => { 8 | // const app = new cdk.App(); 9 | // // WHEN 10 | // const stack = new Cdk.CdkStack(app, 'MyTestStack'); 11 | // // THEN 12 | // const template = Template.fromStack(stack); 13 | 14 | // template.hasResourceProperties('AWS::SQS::Queue', { 15 | // VisibilityTimeout: 300 16 | // }); 17 | }); 18 | -------------------------------------------------------------------------------- /cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "version": "0.1.0", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/jest": "^26.0.10", 15 | "@types/node": "10.17.27", 16 | "jest": "^26.4.2", 17 | "ts-jest": "^26.2.0", 18 | "aws-cdk": "2.64.0", 19 | "ts-node": "^9.0.0", 20 | "typescript": "~3.9.7" 21 | }, 22 | "dependencies": { 23 | "aws-cdk-lib": "2.64.0", 24 | "constructs": "^10.1.247", 25 | "source-map-support": "^0.5.21" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/laravel/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /src/laravel/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /src/laravel/app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/laravel/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /src/laravel/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /src/laravel/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/laravel/app/Jobs/LatencyTest.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /src/laravel/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/runtime/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Fail on error 4 | set -e 5 | 6 | if [ ! -d '/tmp/session' ]; then 7 | mkdir -p /tmp/session 8 | fi 9 | 10 | if [ -f "/var/task/bootstrap" ]; then 11 | echo "Found and Running '/var/task/bootstrap' instead of '/opt/bootstrap'" 12 | exec -- /var/task/bootstrap 13 | else 14 | echo "Running '/opt/bootstrap' when '/var/task/bootstrap' not found" 15 | 16 | if [ -f "/var/task/php/etc/php-fpm.conf" ]; then 17 | /opt/php/bin/php-fpm --force-stderr --fpm-config /var/task/php/etc/php-fpm.conf 18 | else 19 | /opt/php/bin/php-fpm --force-stderr --fpm-config /opt/php/etc/php-fpm.conf 20 | fi 21 | 22 | if [ -f "/var/task/nginx/conf/nginx.conf" ]; then 23 | exec /opt/nginx/bin/nginx -c /var/task/nginx/conf/nginx.conf -g "daemon off;" 24 | else 25 | exec /opt/nginx/bin/nginx -c /opt/nginx/conf/nginx.conf -g "daemon off;" 26 | fi 27 | 28 | fi 29 | -------------------------------------------------------------------------------- /cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts bin/cdk.ts", 3 | "watch": { 4 | "include": [ 5 | "**" 6 | ], 7 | "exclude": [ 8 | "README.md", 9 | "cdk*.json", 10 | "**/*.d.ts", 11 | "**/*.js", 12 | "tsconfig.json", 13 | "package*.json", 14 | "yarn.lock", 15 | "node_modules", 16 | "test" 17 | ] 18 | }, 19 | "context": { 20 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, 21 | "@aws-cdk/core:stackRelativeExports": true, 22 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, 23 | "@aws-cdk/aws-lambda:recognizeVersionProps": true, 24 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, 25 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, 26 | "@aws-cdk/core:target-partitions": [ 27 | "aws", 28 | "aws-cn" 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/laravel/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /src/laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /src/laravel/config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /src/laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/laravel/app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/laravel/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var array 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * The attributes that should be cast. 38 | * 39 | * @var array 40 | */ 41 | protected $casts = [ 42 | 'email_verified_at' => 'datetime', 43 | ]; 44 | } 45 | -------------------------------------------------------------------------------- /src/laravel/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /src/laravel/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class UserFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'name' => fake()->name(), 22 | 'email' => fake()->unique()->safeEmail(), 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | } 28 | 29 | /** 30 | * Indicate that the model's email address should be unverified. 31 | */ 32 | public function unverified(): static 33 | { 34 | return $this->state(fn (array $attributes) => [ 35 | 'email_verified_at' => null, 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/laravel/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/laravel/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | // realpath(storage_path('framework/views')), 34 | realpath('/tmp') 35 | ), 36 | 37 | ]; 38 | -------------------------------------------------------------------------------- /src/runtime/preload.php: -------------------------------------------------------------------------------- 1 | $file) { 20 | 21 | if (opcache_is_script_cached($file[0])) { 22 | continue; 23 | } 24 | 25 | $ignore = false; 26 | foreach ($list as $item) { 27 | if (str_contains($file[0], $item)) { 28 | $ignores[] = $file[0]; 29 | $ignore = true; 30 | break; 31 | } 32 | } 33 | 34 | if ($ignore) { 35 | continue; 36 | } 37 | 38 | try { 39 | @opcache_compile_file($file[0]); 40 | } catch (Throwable $e) { 41 | $msg = $e->getMessage(); 42 | file_put_contents('php://stdout', "preload failed $msg" . PHP_EOL); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/laravel/app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/laravel/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=example_app 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 55 | VITE_PUSHER_HOST="${PUSHER_HOST}" 56 | VITE_PUSHER_PORT="${PUSHER_PORT}" 57 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 58 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 59 | -------------------------------------------------------------------------------- /src/laravel/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /layer.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM public.ecr.aws/awsguru/php:devel.81.2023.3.13.1 AS builder 2 | 3 | #COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.0 /lambda-adapter /opt/extensions/ 4 | 5 | # Your builders code here 6 | # You can install or disable some extensions 7 | # RUN pecl install intl 8 | 9 | RUN /lambda-layer php_disable shmop \ 10 | calendar \ 11 | xmlrpc \ 12 | sysvsem \ 13 | sysvshm \ 14 | pdo_pgsql \ 15 | pgsql \ 16 | bz2 \ 17 | intl \ 18 | ftp \ 19 | awscrt \ 20 | bcmath \ 21 | pdo_sqlite \ 22 | gd \ 23 | sodium \ 24 | igbinary \ 25 | imagick \ 26 | xsl \ 27 | xmlwriter \ 28 | phar \ 29 | && \ 30 | /lambda-layer php_release 31 | 32 | FROM public.ecr.aws/sam/emulation-java11 33 | 34 | COPY --from=builder /opt /opt 35 | COPY --from=builder /lambda-layer /lambda-layer 36 | 37 | RUN rm -rf /opt/php/bin/php && \ 38 | /lambda-layer clean_libs 39 | -------------------------------------------------------------------------------- /src/laravel/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /src/laravel/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /src/laravel/artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /src/laravel/public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /cdk/Makefile: -------------------------------------------------------------------------------- 1 | include .env 2 | export 3 | 4 | .EXPORT_ALL_VARIABLES: 5 | DOCKER_BUILDKIT = 1 6 | 7 | build: php-layer 8 | cd ../ 9 | docker compose up release 10 | docker compose down 11 | 12 | php-layer: 13 | docker build --platform=linux/amd64 ../ --platform=linux/amd64 --tag php-layer --file ../layer.Dockerfile 14 | rm -rf layer 15 | docker run --platform=linux/amd64 --volume ${PWD}:/tmp/ --entrypoint /bin/cp php-layer -r /opt /tmp/layer 16 | docker stop php-layer || true && docker rm php-layer || true 17 | cp -f ../src/runtime/bootstrap layer/bootstrap 18 | cp -f ../src/runtime/nginx.conf layer/nginx/conf/ 19 | cp -f ../src/runtime/php.ini layer/php/php.ini 20 | cp -f ../src/runtime/php-fpm.conf layer/php/etc/ 21 | cp -f ../src/runtime/preload.php layer/php/preload.php 22 | 23 | diff: php-layer build 24 | cdk diff \ 25 | -c LATENCY_VERSION=$(LATENCY_VERSION) \ 26 | -c DB_USER=$(DB_USER) \ 27 | -c RUST_LOG=$(RUST_LOG) \ 28 | -c READINESS_CHECK_PATH=$(READINESS_CHECK_PATH) \ 29 | -c ROUTE53_HOSTEDZONE=$(ROUTE53_HOSTEDZONE) \ 30 | -c ROUTE53_SITENAME=$(ROUTE53_SITENAME) \ 31 | -c PRELOAD_DISABLE=$(PRELOAD_DISABLE) \ 32 | -c SNAPSTART_ENABLE=$(SNAPSTART_ENABLE) \ 33 | -c APP_NAME=$(APP_NAME) 34 | 35 | deploy: php-layer build 36 | cdk deploy \ 37 | -c LATENCY_VERSION=$(LATENCY_VERSION) \ 38 | -c DB_USER=$(DB_USER) \ 39 | -c RUST_LOG=$(RUST_LOG) \ 40 | -c READINESS_CHECK_PATH=$(READINESS_CHECK_PATH) \ 41 | -c ROUTE53_HOSTEDZONE=$(ROUTE53_HOSTEDZONE) \ 42 | -c ROUTE53_SITENAME=$(ROUTE53_SITENAME) \ 43 | -c PRELOAD_DISABLE=$(PRELOAD_DISABLE) \ 44 | -c SNAPSTART_ENABLE=$(SNAPSTART_ENABLE) \ 45 | -c APP_NAME=$(APP_NAME) 46 | 47 | destroy: 48 | cdk destroy \ 49 | -c LATENCY_VERSION=$(LATENCY_VERSION) \ 50 | -c DB_USER=$(DB_USER) \ 51 | -c RUST_LOG=$(RUST_LOG) \ 52 | -c READINESS_CHECK_PATH=$(READINESS_CHECK_PATH) \ 53 | -c ROUTE53_HOSTEDZONE=$(ROUTE53_HOSTEDZONE) \ 54 | -c ROUTE53_SITENAME=$(ROUTE53_SITENAME) \ 55 | -c PRELOAD_DISABLE=$(PRELOAD_DISABLE) \ 56 | -c SNAPSTART_ENABLE=$(SNAPSTART_ENABLE) \ 57 | -c APP_NAME=$(APP_NAME) 58 | -------------------------------------------------------------------------------- /src/laravel/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^8.1", 12 | "guzzlehttp/guzzle": "^7.2", 13 | "laravel/framework": "^10.8", 14 | "laravel/sanctum": "^3.2", 15 | "laravel/tinker": "^2.8", 16 | "league/flysystem-aws-s3-v3": "^3.15" 17 | }, 18 | "require-dev": { 19 | "fakerphp/faker": "^1.9.1", 20 | "laravel/pint": "^1.0", 21 | "laravel/sail": "^1.18", 22 | "mockery/mockery": "^1.4.4", 23 | "nunomaduro/collision": "^7.0", 24 | "phpunit/phpunit": "^10.1", 25 | "spatie/laravel-ignition": "^2.0" 26 | }, 27 | "autoload": { 28 | "psr-4": { 29 | "App\\": "app/", 30 | "Database\\Factories\\": "database/factories/", 31 | "Database\\Seeders\\": "database/seeders/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "Tests\\": "tests/" 37 | } 38 | }, 39 | "scripts": { 40 | "post-autoload-dump": [ 41 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 42 | "@php artisan package:discover --ansi" 43 | ], 44 | "post-update-cmd": [ 45 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 46 | ], 47 | "post-root-package-install": [ 48 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 49 | ], 50 | "post-create-project-cmd": [ 51 | "@php artisan key:generate --ansi" 52 | ] 53 | }, 54 | "extra": { 55 | "laravel": { 56 | "dont-discover": [] 57 | } 58 | }, 59 | "config": { 60 | "optimize-autoloader": true, 61 | "preferred-install": "dist", 62 | "sort-packages": true, 63 | "allow-plugins": { 64 | "pestphp/pest-plugin": true, 65 | "php-http/discovery": true 66 | } 67 | }, 68 | "minimum-stability": "stable", 69 | "prefer-stable": true 70 | } 71 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | release: 4 | image: public.ecr.aws/awsguru/php:devel.81.2023.3.13.1 5 | working_dir: /var/task 6 | entrypoint: /build.sh 7 | volumes: 8 | - ./build.sh:/build.sh 9 | - ./tmp/tmp:/tmp 10 | - ./tmp/efs:/mnt/share 11 | - ./src/laravel:/var/task 12 | build: 13 | image: public.ecr.aws/awsguru/php:devel.81.2023.3.13.1 14 | working_dir: /var/task 15 | entrypoint: /build.sh 16 | volumes: 17 | - ./build.sh:/build.sh 18 | - ./tmp/tmp:/tmp 19 | - ./tmp/efs:/mnt/share 20 | - ./src/laravel:/var/task 21 | web: 22 | image: public.ecr.aws/awsguru/php:devel.81.2023.3.13.1 23 | working_dir: /var/task 24 | entrypoint: /opt/bootstrap 25 | ports: 26 | - "8000:8000" 27 | volumes: 28 | - ./tmp/efs:/mnt/share 29 | - ./tmp/tmp:/tmp 30 | - ./tmp/nginx:/var/log/nginx 31 | - ~/.aws/credentials:/root/.aws/credentials 32 | - ./src/laravel:/var/task 33 | - ./src/runtime/preload.php:/opt/php/preload.php 34 | - ./src/runtime/nginx.conf:/opt/nginx/conf/nginx.conf 35 | - ./src/runtime/php-fpm.conf:/opt/php/etc/php-fpm.conf 36 | - ./src/runtime/php-dev.ini:/opt/php/php.ini 37 | - ./src/runtime/bootstrap_dev:/opt/bootstrap 38 | links: 39 | - mysql 40 | - redis 41 | depends_on: 42 | - mysql 43 | - redis 44 | environment: 45 | RUST_LOG: info 46 | AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap 47 | PRELOAD_DISABLE: true 48 | REDIS_PORT: 6379 49 | DB_HOST: 'mysql' 50 | DB_PORT: 3306 51 | DB_DATABASE: 'mysql' 52 | DB_USERNAME: 'root' 53 | DB_PASSWORD: 'root' 54 | APP_ENV: local 55 | LOG_CHANNEL: stdout 56 | CACHE_DRIVER: redis 57 | SESSION_DRIVER: redis 58 | FILESYSTEM_DISK: s3 59 | read_only: true 60 | mysql: 61 | image: mysql 62 | restart: always 63 | ports: 64 | - "3306:3306" 65 | volumes: 66 | - ./tmp/mysql:/var/lib/mysql 67 | environment: 68 | MYSQL_DATABASE: root 69 | MYSQL_ROOT_PASSWORD: root 70 | redis: 71 | image: redis 72 | restart: always 73 | ports: 74 | - "6379:6379" 75 | volumes: 76 | - ./tmp/redis:/data 77 | command: redis-server --appendonly yes 78 | -------------------------------------------------------------------------------- /src/laravel/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 40 | 'port' => env('PUSHER_PORT', 443), 41 | 'scheme' => env('PUSHER_SCHEME', 'https'), 42 | 'encrypted' => true, 43 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 44 | ], 45 | 'client_options' => [ 46 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 47 | ], 48 | ], 49 | 50 | 'ably' => [ 51 | 'driver' => 'ably', 52 | 'key' => env('ABLY_KEY'), 53 | ], 54 | 55 | 'redis' => [ 56 | 'driver' => 'redis', 57 | 'connection' => 'default', 58 | ], 59 | 60 | 'log' => [ 61 | 'driver' => 'log', 62 | ], 63 | 64 | 'null' => [ 65 | 'driver' => 'null', 66 | ], 67 | 68 | ], 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel on Lambda 2 | 3 | Your Laravel can run directly on Lambda with [AWS Lambda Web Adapter](https://github.com/awslabs/aws-lambda-web-adapter) 4 | 5 | This is the code used for Laravel on Lambda with Snapstart. 6 | 7 | ## Prerequisites 8 | 9 | To build and deploy this stack, please have the following tools installed. 10 | 11 | - Docker 12 | - Node.js 13 | - AWS CLI 14 | - AWS CDK 15 | 16 | You also need a DNS domain hosted on Route53. 17 | 18 | ## Configuration Laravel 19 | 20 | Set up your `.env` file. 21 | 22 | ```shell 23 | $ cd src/laravel 24 | $ cp .env.example .env 25 | $ composer install --prefer-dist --optimize-autoloader --no-interaction 26 | $ php artisan key:generate 27 | ``` 28 | 29 | Use S3 as Filesystem: 30 | 31 | ```dotenv 32 | FILESYSTEM_DISK=s3 33 | ``` 34 | 35 | Use stdout as Log: 36 | 37 | ```dotenv 38 | LOG_CHANNEL=stdout 39 | ``` 40 | 41 | Edit `config/logging.php` -> `channels` 42 | 43 | ```php 44 | 'channels' => [ 45 | // ... 46 | 'stdout' => [ 47 | 'driver' => 'monolog', 48 | 'handler' => StreamHandler::class, 49 | 'with' => [ 50 | 'stream' => 'php://stdout', 51 | ], 52 | 'formatter' => env('LOG_STDOUT_FORMATTER'), 53 | ], 54 | // ... 55 | ] 56 | ``` 57 | 58 | Use `redis` as Cache and Session driver: 59 | 60 | ```dotenv 61 | CACHE_DRIVER=redis 62 | SESSION_DRIVER=redis 63 | REDIS_PORT=6379 64 | ``` 65 | 66 | ## Configuration CDK 67 | 68 | This stack use `.env` file to provide configuration values. 69 | 70 | Copy cdk/.env.example to cdk/.env and update the values to fit your needs. 71 | 72 | Then install CDK dependencies 73 | 74 | ```shell 75 | cd cdk 76 | 77 | # Please follow the example to configure 78 | cp .env.example .env 79 | 80 | npm install 81 | ``` 82 | 83 | ## Deployment 84 | 85 | Preview the changes 86 | 87 | ```shell 88 | make diff 89 | ``` 90 | 91 | Deploy the stack 92 | 93 | ```shell 94 | make deploy 95 | ```` 96 | 97 | When the deployment is done, open `ROUTE53_SITENAME` to view the home page. 98 | 99 | ## Clean up 100 | 101 | Run the following command to delete ALL the resources deployed for this project, including the database, redis cluster 102 | and S3 bucket. 103 | 104 | ```shell 105 | make destroy 106 | ``` 107 | 108 | ## Security 109 | 110 | See [CONTRIBUTING](CONTRIBUTING.md) for more information. 111 | 112 | ## License 113 | 114 | This library is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file. 115 | -------------------------------------------------------------------------------- /src/laravel/config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. If this value is null, personal access tokens do 45 | | not expire. This won't tweak the lifetime of first-party sessions. 46 | | 47 | */ 48 | 49 | 'expiration' => null, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Sanctum Middleware 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When authenticating your first-party SPA with Sanctum you may need to 57 | | customize some of the middleware Sanctum uses while processing the 58 | | request. You may change the middleware listed below as required. 59 | | 60 | */ 61 | 62 | 'middleware' => [ 63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /src/laravel/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been set up for each driver as an example of the required values. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /src/laravel/app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | ], 40 | 41 | 'api' => [ 42 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 43 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's middleware aliases. 50 | * 51 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. 52 | * 53 | * @var array 54 | */ 55 | protected $middlewareAliases = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'signed' => \App\Http\Middleware\ValidateSignature::class, 64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 66 | ]; 67 | } 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /src/laravel/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | laravel.test: 4 | build: 5 | context: ./vendor/laravel/sail/runtimes/8.2 6 | dockerfile: Dockerfile 7 | args: 8 | WWWGROUP: '${WWWGROUP}' 9 | image: sail-8.2/app 10 | extra_hosts: 11 | - 'host.docker.internal:host-gateway' 12 | ports: 13 | - '${APP_PORT:-80}:80' 14 | - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' 15 | environment: 16 | WWWUSER: '${WWWUSER}' 17 | LARAVEL_SAIL: 1 18 | XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' 19 | XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' 20 | IGNITION_LOCAL_SITES_PATH: '${PWD}' 21 | volumes: 22 | - '.:/var/www/html' 23 | networks: 24 | - sail 25 | depends_on: 26 | - mysql 27 | - redis 28 | - meilisearch 29 | - mailpit 30 | - selenium 31 | mysql: 32 | image: 'mysql/mysql-server:8.0' 33 | ports: 34 | - '${FORWARD_DB_PORT:-3306}:3306' 35 | environment: 36 | MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' 37 | MYSQL_ROOT_HOST: '%' 38 | MYSQL_DATABASE: '${DB_DATABASE}' 39 | MYSQL_USER: '${DB_USERNAME}' 40 | MYSQL_PASSWORD: '${DB_PASSWORD}' 41 | MYSQL_ALLOW_EMPTY_PASSWORD: 1 42 | volumes: 43 | - 'sail-mysql:/var/lib/mysql' 44 | - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' 45 | networks: 46 | - sail 47 | healthcheck: 48 | test: 49 | - CMD 50 | - mysqladmin 51 | - ping 52 | - '-p${DB_PASSWORD}' 53 | retries: 3 54 | timeout: 5s 55 | redis: 56 | image: 'redis:alpine' 57 | ports: 58 | - '${FORWARD_REDIS_PORT:-6379}:6379' 59 | volumes: 60 | - 'sail-redis:/data' 61 | networks: 62 | - sail 63 | healthcheck: 64 | test: 65 | - CMD 66 | - redis-cli 67 | - ping 68 | retries: 3 69 | timeout: 5s 70 | meilisearch: 71 | image: 'getmeili/meilisearch:latest' 72 | ports: 73 | - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' 74 | volumes: 75 | - 'sail-meilisearch:/meili_data' 76 | networks: 77 | - sail 78 | healthcheck: 79 | test: 80 | - CMD 81 | - wget 82 | - '--no-verbose' 83 | - '--spider' 84 | - 'http://localhost:7700/health' 85 | retries: 3 86 | timeout: 5s 87 | mailpit: 88 | image: 'axllent/mailpit:latest' 89 | ports: 90 | - '${FORWARD_MAILPIT_PORT:-1025}:1025' 91 | - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' 92 | networks: 93 | - sail 94 | selenium: 95 | image: seleniarm/standalone-chromium 96 | extra_hosts: 97 | - 'host.docker.internal:host-gateway' 98 | volumes: 99 | - '/dev/shm:/dev/shm' 100 | networks: 101 | - sail 102 | networks: 103 | sail: 104 | driver: bridge 105 | volumes: 106 | sail-mysql: 107 | driver: local 108 | sail-redis: 109 | driver: local 110 | sail-meilisearch: 111 | driver: local 112 | -------------------------------------------------------------------------------- /src/laravel/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | ], 56 | 57 | 'memcached' => [ 58 | 'driver' => 'memcached', 59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 60 | 'sasl' => [ 61 | env('MEMCACHED_USERNAME'), 62 | env('MEMCACHED_PASSWORD'), 63 | ], 64 | 'options' => [ 65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 66 | ], 67 | 'servers' => [ 68 | [ 69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 70 | 'port' => env('MEMCACHED_PORT', 11211), 71 | 'weight' => 100, 72 | ], 73 | ], 74 | ], 75 | 76 | 'redis' => [ 77 | 'driver' => 'redis', 78 | 'connection' => 'cache', 79 | 'lock_connection' => 'default', 80 | ], 81 | 82 | 'dynamodb' => [ 83 | 'driver' => 'dynamodb', 84 | 'key' => env('AWS_ACCESS_KEY_ID'), 85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 88 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 89 | ], 90 | 91 | 'octane' => [ 92 | 'driver' => 'octane', 93 | ], 94 | 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Cache Key Prefix 100 | |-------------------------------------------------------------------------- 101 | | 102 | | When utilizing the APC, database, memcached, Redis, or DynamoDB cache 103 | | stores there might be other applications using the same cache. For 104 | | that reason, you may prefix every cache key to avoid collisions. 105 | | 106 | */ 107 | 108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /src/laravel/config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Job Batching 79 | |-------------------------------------------------------------------------- 80 | | 81 | | The following options configure the database and table that store job 82 | | batching information. These options can be updated to any database 83 | | connection and table which has been defined by your application. 84 | | 85 | */ 86 | 87 | 'batching' => [ 88 | 'database' => env('DB_CONNECTION', 'mysql'), 89 | 'table' => 'job_batches', 90 | ], 91 | 92 | /* 93 | |-------------------------------------------------------------------------- 94 | | Failed Queue Jobs 95 | |-------------------------------------------------------------------------- 96 | | 97 | | These options configure the behavior of failed queue job logging so you 98 | | can control which database and table are used to store the jobs that 99 | | have failed. You may change them to any database / table you wish. 100 | | 101 | */ 102 | 103 | 'failed' => [ 104 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 105 | 'database' => env('DB_CONNECTION', 'mysql'), 106 | 'table' => 'failed_jobs', 107 | ], 108 | 109 | ]; 110 | -------------------------------------------------------------------------------- /src/laravel/routes/web.php: -------------------------------------------------------------------------------- 1 | map(function (string $name) { 50 | return strtoupper($name); 51 | })->reject(function (string $name) { 52 | return empty($name); 53 | }); 54 | 55 | __('messages.welcome'); 56 | 57 | LatencyTest::dispatchSync(); 58 | 59 | app(); 60 | config('null'); 61 | session('key'); 62 | request('null'); 63 | url()->current(); 64 | request()->validate([ 65 | 'title' => 'max:255', 66 | ]); 67 | env('APP_ENV'); 68 | public_path(); 69 | resource_path(); 70 | 71 | Arr::accessible(['a' => 1, 'b' => 2]); 72 | Arr::accessible(new Collection); 73 | Arr::add(['name' => 'Desk'], 'price', 100); 74 | Route::currentRouteName(); 75 | Crypt::encrypt("test"); 76 | Hash::make("test"); 77 | Request::getBaseUrl(); 78 | DB::enableQueryLog(); 79 | DB::getDatabaseName(); 80 | 81 | Process::run('ls -la')->successful(); 82 | 83 | RateLimiter::attempt( 84 | 'send-message:RateLimiter', 85 | 5, 86 | function () { 87 | return 'ok'; 88 | } 89 | ); 90 | 91 | Redis::set('name', 'Taylor'); 92 | 93 | Http::timeout(1)->get('https://ip-ranges.amazonaws.com/ip-ranges.json'); 94 | 95 | DB::raw(`show databases;`); 96 | DB::enableQueryLog(); 97 | 98 | try { 99 | (new \Aws\Ecr\EcrClient([ 100 | 'region' => 'ap-southeast-1', 101 | 'version' => 'latest', 102 | ]))->describeRepositories(); 103 | } catch (Throwable $exception) { 104 | } 105 | 106 | } catch (Throwable $exception) { 107 | $result['error'] = $exception->getMessage(); 108 | } 109 | 110 | $result['ms_from_app'] = Helper::ms() - Helper::ms(LARAVEL_START); 111 | $result['ms_from_request'] = Helper::ms() - Helper::ms(request('request_at', 0)); 112 | 113 | if (opcache_get_status()) { 114 | $opcache_statistics = opcache_get_status()['opcache_statistics']; 115 | $result['num_cached_scripts'] = $opcache_statistics['num_cached_scripts']; 116 | } 117 | 118 | return $result; 119 | }); 120 | 121 | Route::get('/phpinfo', function () { 122 | 123 | Log::info('phpinfo'); 124 | 125 | return phpinfo(); 126 | }); 127 | -------------------------------------------------------------------------------- /src/laravel/README.md: -------------------------------------------------------------------------------- 1 |

Laravel Logo

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. 27 | 28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. 29 | 30 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. 31 | 32 | ## Laravel Sponsors 33 | 34 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). 35 | 36 | ### Premium Partners 37 | 38 | - **[Vehikl](https://vehikl.com/)** 39 | - **[Tighten Co.](https://tighten.co)** 40 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 41 | - **[64 Robots](https://64robots.com)** 42 | - **[Cubet Techno Labs](https://cubettech.com)** 43 | - **[Cyber-Duck](https://cyber-duck.co.uk)** 44 | - **[Many](https://www.many.co.uk)** 45 | - **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** 46 | - **[DevSquad](https://devsquad.com)** 47 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 48 | - **[OP.GG](https://op.gg)** 49 | - **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** 50 | - **[Lendio](https://lendio.com)** 51 | 52 | ## Contributing 53 | 54 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 55 | 56 | ## Code of Conduct 57 | 58 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). 59 | 60 | ## Security Vulnerabilities 61 | 62 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. 63 | 64 | ## License 65 | 66 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 67 | -------------------------------------------------------------------------------- /src/laravel/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 32 | | "postmark", "log", "array", "failover" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'local_domain' => env('MAIL_EHLO_DOMAIN'), 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | // 'client' => [ 55 | // 'timeout' => 5, 56 | // ], 57 | ], 58 | 59 | 'postmark' => [ 60 | 'transport' => 'postmark', 61 | // 'client' => [ 62 | // 'timeout' => 5, 63 | // ], 64 | ], 65 | 66 | 'sendmail' => [ 67 | 'transport' => 'sendmail', 68 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 69 | ], 70 | 71 | 'log' => [ 72 | 'transport' => 'log', 73 | 'channel' => env('MAIL_LOG_CHANNEL'), 74 | ], 75 | 76 | 'array' => [ 77 | 'transport' => 'array', 78 | ], 79 | 80 | 'failover' => [ 81 | 'transport' => 'failover', 82 | 'mailers' => [ 83 | 'smtp', 84 | 'log', 85 | ], 86 | ], 87 | ], 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Global "From" Address 92 | |-------------------------------------------------------------------------- 93 | | 94 | | You may wish for all e-mails sent by your application to be sent from 95 | | the same address. Here, you may specify a name and address that is 96 | | used globally for all e-mails that are sent by your application. 97 | | 98 | */ 99 | 100 | 'from' => [ 101 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 102 | 'name' => env('MAIL_FROM_NAME', 'Example'), 103 | ], 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Markdown Mail Settings 108 | |-------------------------------------------------------------------------- 109 | | 110 | | If you are using Markdown based email rendering, you may configure your 111 | | theme and component paths here, allowing you to customize the design 112 | | of the emails. Or, you may simply stick with the Laravel defaults! 113 | | 114 | */ 115 | 116 | 'markdown' => [ 117 | 'theme' => 'default', 118 | 119 | 'paths' => [ 120 | resource_path('views/vendor/mail'), 121 | ], 122 | ], 123 | 124 | ]; 125 | -------------------------------------------------------------------------------- /src/laravel/config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication drivers have a user provider. This defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | mechanisms used by this application to persist your user's data. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | sources which represent each model / table. These sources may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => App\Models\User::class, 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | You may specify multiple password reset configurations if you have more 80 | | than one user table or model in the application and you want to have 81 | | separate password reset settings based on the specific user types. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => 'password_reset_tokens', 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | times out and the user is prompted to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => 10800, 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /src/runtime/nginx.conf: -------------------------------------------------------------------------------- 1 | # For more information on configuration, see: 2 | # * Official English Documentation: http://nginx.org/en/docs/ 3 | 4 | error_log /dev/stderr; 5 | user nobody; 6 | worker_rlimit_core 100m; 7 | working_directory /tmp; 8 | worker_processes 1; 9 | pid /tmp/nginx.pid; 10 | 11 | events { 12 | worker_connections 1024; 13 | } 14 | 15 | http { 16 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 17 | '$status $body_bytes_sent "$http_referer" ' 18 | '"$http_user_agent" "$http_x_forwarded_for"'; 19 | 20 | access_log /dev/stdout main; 21 | error_log /dev/stderr; 22 | 23 | sendfile on; 24 | tcp_nopush on; 25 | tcp_nodelay on; 26 | keepalive_timeout 900; 27 | types_hash_max_size 4096; 28 | 29 | chunked_transfer_encoding off; 30 | 31 | include /opt/nginx/conf/mime.types; 32 | default_type application/octet-stream; 33 | 34 | server { 35 | listen 8080; 36 | server_name _; 37 | root /var/task/public; 38 | 39 | # enable relative redirect 40 | absolute_redirect off; 41 | 42 | client_max_body_size 6m; 43 | 44 | # pass the PHP scripts to FastCGI server 45 | index index.php; 46 | 47 | location = /favicon.ico { 48 | log_not_found off; 49 | access_log off; 50 | } 51 | 52 | location = /robots.txt { 53 | allow all; 54 | log_not_found off; 55 | access_log off; 56 | } 57 | 58 | # Prevent PHP scripts from being executed inside the uploads folder. 59 | location ~* /app/uploads/.*.php$ { 60 | deny all; 61 | } 62 | 63 | location / { 64 | # This is cool because no php is touched for static content. 65 | # include the "?$args" part so non-default permalinks doesn't break when using query string 66 | try_files $uri $uri/ /index.php?$args; 67 | } 68 | 69 | # Add trailing slash to */wp-admin requests. 70 | rewrite /wp-admin$ $uri/ permanent; 71 | 72 | location ~ \.php$ { 73 | fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$; 74 | 75 | fastcgi_pass 127.0.0.1:3000; 76 | fastcgi_index index.php; 77 | 78 | include /opt/nginx/conf/fastcgi_params; 79 | 80 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 81 | fastcgi_param PATH_INFO $fastcgi_path_info; 82 | 83 | fastcgi_read_timeout 900s; 84 | 85 | # workaround for passing on real Host header 86 | fastcgi_param SERVER_NAME $http_x_forwarded_host; 87 | fastcgi_param HTTP_HOST $http_x_forwarded_host; 88 | 89 | if ($http_x_forwarded_proto = 'https') { 90 | set $fe_https 'on'; 91 | } 92 | fastcgi_param HTTPS $fe_https if_not_empty; 93 | } 94 | 95 | # BEGIN W3TC Browser Cache 96 | gzip on; 97 | gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon application/json application/vnd.ms-access video/webm application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel; 98 | location ~ \.(css|htc|less|js|js2|js3|js4)$ { 99 | expires 31536000s; 100 | etag on; 101 | if_modified_since exact; 102 | try_files $uri $uri/ /index.php?$args; 103 | } 104 | location ~ \.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$ { 105 | etag on; 106 | if_modified_since exact; 107 | try_files $uri $uri/ /index.php?$args; 108 | } 109 | location ~ \.(asf|asx|wax|wmv|wmx|avi|avif|avifs|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|_ttf|wav|wma|woff|woff2|wri|xla|xls|xlsx|xlt|xlw|zip)$ { 110 | expires 31536000s; 111 | etag on; 112 | if_modified_since exact; 113 | try_files $uri $uri/ /index.php?$args; 114 | } 115 | add_header Referrer-Policy "no-referrer-when-downgrade"; 116 | # END W3TC Browser Cache 117 | 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/laravel/config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => false, 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Out of 45 | | the box, Laravel uses the Monolog PHP logging library. This gives 46 | | you a variety of powerful log handlers / formatters to utilize. 47 | | 48 | | Available Drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", 50 | | "custom", "stack" 51 | | 52 | */ 53 | 54 | 'channels' => [ 55 | 56 | 'stdout' => [ 57 | 'driver' => 'monolog', 58 | 'handler' => StreamHandler::class, 59 | 'with' => [ 60 | 'stream' => 'php://stdout', 61 | ], 62 | 'formatter' => env('LOG_STDOUT_FORMATTER'), 63 | ], 64 | 65 | 'stack' => [ 66 | 'driver' => 'stack', 67 | 'channels' => ['stdout'], 68 | 'ignore_exceptions' => false, 69 | ], 70 | 71 | 'single' => [ 72 | 'driver' => 'single', 73 | 'path' => storage_path('logs/laravel.log'), 74 | 'level' => env('LOG_LEVEL', 'debug'), 75 | 'replace_placeholders' => true, 76 | ], 77 | 78 | 'daily' => [ 79 | 'driver' => 'daily', 80 | 'path' => storage_path('logs/laravel.log'), 81 | 'level' => env('LOG_LEVEL', 'debug'), 82 | 'days' => 14, 83 | 'replace_placeholders' => true, 84 | ], 85 | 86 | 'slack' => [ 87 | 'driver' => 'slack', 88 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 89 | 'username' => 'Laravel Log', 90 | 'emoji' => ':boom:', 91 | 'level' => env('LOG_LEVEL', 'critical'), 92 | 'replace_placeholders' => true, 93 | ], 94 | 95 | 'papertrail' => [ 96 | 'driver' => 'monolog', 97 | 'level' => env('LOG_LEVEL', 'debug'), 98 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 99 | 'handler_with' => [ 100 | 'host' => env('PAPERTRAIL_URL'), 101 | 'port' => env('PAPERTRAIL_PORT'), 102 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 103 | ], 104 | 'processors' => [PsrLogMessageProcessor::class], 105 | ], 106 | 107 | 'stderr' => [ 108 | 'driver' => 'monolog', 109 | 'level' => env('LOG_LEVEL', 'debug'), 110 | 'handler' => StreamHandler::class, 111 | 'formatter' => env('LOG_STDERR_FORMATTER'), 112 | 'with' => [ 113 | 'stream' => 'php://stderr', 114 | ], 115 | 'processors' => [PsrLogMessageProcessor::class], 116 | ], 117 | 118 | 'syslog' => [ 119 | 'driver' => 'syslog', 120 | 'level' => env('LOG_LEVEL', 'debug'), 121 | 'facility' => LOG_USER, 122 | 'replace_placeholders' => true, 123 | ], 124 | 125 | 'errorlog' => [ 126 | 'driver' => 'errorlog', 127 | 'level' => env('LOG_LEVEL', 'debug'), 128 | 'replace_placeholders' => true, 129 | ], 130 | 131 | 'null' => [ 132 | 'driver' => 'monolog', 133 | 'handler' => NullHandler::class, 134 | ], 135 | 136 | 'emergency' => [ 137 | 'path' => storage_path('logs/laravel.log'), 138 | ], 139 | ], 140 | 141 | ]; 142 | -------------------------------------------------------------------------------- /src/laravel/config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'search_path' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 93 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 94 | ], 95 | 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Migration Repository Table 101 | |-------------------------------------------------------------------------- 102 | | 103 | | This table keeps track of all the migrations that have already run for 104 | | your application. Using this information, we can determine which of 105 | | the migrations on disk haven't actually been run in the database. 106 | | 107 | */ 108 | 109 | 'migrations' => 'migrations', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Redis Databases 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Redis is an open source, fast, and advanced key-value store that also 117 | | provides a richer body of commands than a typical key-value system 118 | | such as APC or Memcached. Laravel makes it easy to dig right in. 119 | | 120 | */ 121 | 122 | 'redis' => [ 123 | 124 | 'client' => env('REDIS_CLIENT', 'phpredis'), 125 | 126 | 'options' => [ 127 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 128 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 129 | ], 130 | 131 | 'default' => [ 132 | 'url' => env('REDIS_URL'), 133 | 'host' => env('REDIS_HOST', '127.0.0.1'), 134 | 'username' => env('REDIS_USERNAME'), 135 | 'password' => env('REDIS_PASSWORD'), 136 | 'port' => env('REDIS_PORT', '6379'), 137 | 'database' => env('REDIS_DB', '0'), 138 | ], 139 | 140 | 'cache' => [ 141 | 'url' => env('REDIS_URL'), 142 | 'host' => env('REDIS_HOST', '127.0.0.1'), 143 | 'username' => env('REDIS_USERNAME'), 144 | 'password' => env('REDIS_PASSWORD'), 145 | 'port' => env('REDIS_PORT', '6379'), 146 | 'database' => env('REDIS_CACHE_DB', '1'), 147 | ], 148 | 149 | ], 150 | 151 | ]; 152 | -------------------------------------------------------------------------------- /src/laravel/config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Application Environment 24 | |-------------------------------------------------------------------------- 25 | | 26 | | This value determines the "environment" your application is currently 27 | | running in. This may determine how you prefer to configure various 28 | | services the application utilizes. Set this in your ".env" file. 29 | | 30 | */ 31 | 32 | 'env' => env('APP_ENV', 'production'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Application Debug Mode 37 | |-------------------------------------------------------------------------- 38 | | 39 | | When your application is in debug mode, detailed error messages with 40 | | stack traces will be shown on every error that occurs within your 41 | | application. If disabled, a simple generic error page is shown. 42 | | 43 | */ 44 | 45 | 'debug' => (bool) env('APP_DEBUG', false), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Application URL 50 | |-------------------------------------------------------------------------- 51 | | 52 | | This URL is used by the console to properly generate URLs when using 53 | | the Artisan command line tool. You should set this to the root of 54 | | your application so that it is used when running Artisan tasks. 55 | | 56 | */ 57 | 58 | 'url' => env('APP_URL', 'http://localhost'), 59 | 60 | 'asset_url' => env('ASSET_URL'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Application Timezone 65 | |-------------------------------------------------------------------------- 66 | | 67 | | Here you may specify the default timezone for your application, which 68 | | will be used by the PHP date and date-time functions. We have gone 69 | | ahead and set this to a sensible default for you out of the box. 70 | | 71 | */ 72 | 73 | 'timezone' => 'UTC', 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Application Locale Configuration 78 | |-------------------------------------------------------------------------- 79 | | 80 | | The application locale determines the default locale that will be used 81 | | by the translation service provider. You are free to set this value 82 | | to any of the locales which will be supported by the application. 83 | | 84 | */ 85 | 86 | 'locale' => 'en', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Application Fallback Locale 91 | |-------------------------------------------------------------------------- 92 | | 93 | | The fallback locale determines the locale to use when the current one 94 | | is not available. You may change the value to correspond to any of 95 | | the language folders that are provided through your application. 96 | | 97 | */ 98 | 99 | 'fallback_locale' => 'en', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Faker Locale 104 | |-------------------------------------------------------------------------- 105 | | 106 | | This locale will be used by the Faker PHP library when generating fake 107 | | data for your database seeds. For example, this will be used to get 108 | | localized telephone numbers, street address information and more. 109 | | 110 | */ 111 | 112 | 'faker_locale' => 'en_US', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Encryption Key 117 | |-------------------------------------------------------------------------- 118 | | 119 | | This key is used by the Illuminate encrypter service and should be set 120 | | to a random, 32 character string, otherwise these encrypted strings 121 | | will not be safe. Please do this before deploying an application! 122 | | 123 | */ 124 | 125 | 'key' => env('APP_KEY'), 126 | 127 | 'cipher' => 'AES-256-CBC', 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Maintenance Mode Driver 132 | |-------------------------------------------------------------------------- 133 | | 134 | | These configuration options determine the driver used to determine and 135 | | manage Laravel's "maintenance mode" status. The "cache" driver will 136 | | allow maintenance mode to be controlled across multiple machines. 137 | | 138 | | Supported drivers: "file", "cache" 139 | | 140 | */ 141 | 142 | 'maintenance' => [ 143 | 'driver' => 'file', 144 | // 'store' => 'redis', 145 | ], 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Autoloaded Service Providers 150 | |-------------------------------------------------------------------------- 151 | | 152 | | The service providers listed here will be automatically loaded on the 153 | | request to your application. Feel free to add your own services to 154 | | this array to grant expanded functionality to your applications. 155 | | 156 | */ 157 | 158 | 'providers' => ServiceProvider::defaultProviders()->merge([ 159 | /* 160 | * Package Service Providers... 161 | */ 162 | 163 | /* 164 | * Application Service Providers... 165 | */ 166 | App\Providers\AppServiceProvider::class, 167 | App\Providers\AuthServiceProvider::class, 168 | // App\Providers\BroadcastServiceProvider::class, 169 | App\Providers\EventServiceProvider::class, 170 | App\Providers\RouteServiceProvider::class, 171 | ])->toArray(), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | Class Aliases 176 | |-------------------------------------------------------------------------- 177 | | 178 | | This array of class aliases will be registered when this application 179 | | is started. However, feel free to register as many as you wish as 180 | | the aliases are "lazy" loaded so they don't hinder performance. 181 | | 182 | */ 183 | 184 | 'aliases' => Facade::defaultAliases()->merge([ 185 | // 'Example' => App\Facades\Example::class, 186 | ])->toArray(), 187 | 188 | ]; 189 | -------------------------------------------------------------------------------- /src/laravel/config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION'), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | While using one of the framework's cache driven session backends you may 96 | | list a cache store that should be used for these sessions. This value 97 | | must match with one of the application's configured cache "stores". 98 | | 99 | | Affects: "apc", "dynamodb", "memcached", "redis" 100 | | 101 | */ 102 | 103 | 'store' => env('SESSION_STORE'), 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Session Sweeping Lottery 108 | |-------------------------------------------------------------------------- 109 | | 110 | | Some session drivers must manually sweep their storage location to get 111 | | rid of old sessions from storage. Here are the chances that it will 112 | | happen on a given request. By default, the odds are 2 out of 100. 113 | | 114 | */ 115 | 116 | 'lottery' => [2, 100], 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Session Cookie Name 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Here you may change the name of the cookie used to identify a session 124 | | instance by ID. The name specified here will get used every time a 125 | | new session cookie is created by the framework for every driver. 126 | | 127 | */ 128 | 129 | 'cookie' => env( 130 | 'SESSION_COOKIE', 131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 132 | ), 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Session Cookie Path 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The session cookie path determines the path for which the cookie will 140 | | be regarded as available. Typically, this will be the root path of 141 | | your application but you are free to change this when necessary. 142 | | 143 | */ 144 | 145 | 'path' => '/', 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Session Cookie Domain 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Here you may change the domain of the cookie used to identify a session 153 | | in your application. This will determine which domains the cookie is 154 | | available to in your application. A sensible default has been set. 155 | | 156 | */ 157 | 158 | 'domain' => env('SESSION_DOMAIN'), 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | HTTPS Only Cookies 163 | |-------------------------------------------------------------------------- 164 | | 165 | | By setting this option to true, session cookies will only be sent back 166 | | to the server if the browser has a HTTPS connection. This will keep 167 | | the cookie from being sent to you when it can't be done securely. 168 | | 169 | */ 170 | 171 | 'secure' => env('SESSION_SECURE_COOKIE'), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | HTTP Access Only 176 | |-------------------------------------------------------------------------- 177 | | 178 | | Setting this value to true will prevent JavaScript from accessing the 179 | | value of the cookie and the cookie will only be accessible through 180 | | the HTTP protocol. You are free to modify this option if needed. 181 | | 182 | */ 183 | 184 | 'http_only' => true, 185 | 186 | /* 187 | |-------------------------------------------------------------------------- 188 | | Same-Site Cookies 189 | |-------------------------------------------------------------------------- 190 | | 191 | | This option determines how your cookies behave when cross-site requests 192 | | take place, and can be used to mitigate CSRF attacks. By default, we 193 | | will set this value to "lax" since this is a secure default value. 194 | | 195 | | Supported: "lax", "strict", "none", null 196 | | 197 | */ 198 | 199 | 'same_site' => 'lax', 200 | 201 | ]; 202 | -------------------------------------------------------------------------------- /src/runtime/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | ; All relative paths in this configuration file are relative to PHP's install 6 | ; prefix (/opt/php). This prefix can be dynamically changed by using the 7 | ; '-p' argument from the command line. 8 | 9 | ;;;;;;;;;;;;;;;;;; 10 | ; Global Options ; 11 | ;;;;;;;;;;;;;;;;;; 12 | 13 | [global] 14 | ; Pid file 15 | ; Note: the default prefix is /opt/php/var 16 | ; Default Value: none 17 | pid = /tmp/php-fpm.pid 18 | 19 | ; Error log file 20 | ; If it's set to "syslog", log is sent to syslogd instead of being written 21 | ; into a local file. 22 | ; Note: the default prefix is /opt/php/var 23 | ; Default Value: log/php-fpm.log 24 | error_log = /dev/stderr 25 | 26 | ; Log limit on number of characters in the single line (log entry). If the 27 | ; line is over the limit, it is wrapped on multiple lines. The limit is for 28 | ; all logged characters including message prefix and suffix if present. However 29 | ; the new line character does not count into it as it is present only when 30 | ; logging to a file descriptor. It means the new line character is not present 31 | ; when logging to syslog. 32 | ; Default Value: 1024 33 | log_limit = 8192 34 | 35 | 36 | ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. 37 | ; Default Value: yes 38 | daemonize = yes 39 | 40 | ; Set max core size rlimit for the master process. 41 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 42 | ; Default Value: system defined value 43 | ; Limit the number of core dump logs to 1 to avoid filling up the /tmp disk 44 | rlimit_core = 1 45 | 46 | ;;;;;;;;;;;;;;;;;;;; 47 | ; Pool Definitions ; 48 | ;;;;;;;;;;;;;;;;;;;; 49 | 50 | ; Multiple pools of child processes may be started with different listening 51 | ; ports and different management options. The name of the pool will be 52 | ; used in logs and stats. There is no limitation on the number of pools which 53 | ; FPM can handle. Your system will tell you anyway :) 54 | 55 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 56 | ; files from a glob(3) pattern. This directive can be used everywhere in the 57 | ; file. 58 | ; Relative path can also be used. They will be prefixed by: 59 | ; - the global prefix if it's been set (-p argument) 60 | ; - /opt/php otherwise 61 | ;include=/vat/task/php-fpm/*.conf 62 | 63 | ; Start a new pool named 'www'. 64 | ; the variable $pool can be used in any directive and will be replaced by the 65 | ; pool name ('www' here) 66 | [www] 67 | 68 | ; Unix user/group of processes 69 | ; Note: The user is mandatory. If the group is not set, the default user's group 70 | ; will be used. 71 | user = nobody 72 | group = nobody 73 | 74 | ; The address on which to accept FastCGI requests. 75 | ; Valid syntaxes are: 76 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 77 | ; a specific port; 78 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 79 | ; a specific port; 80 | ; 'port' - to listen on a TCP socket to all addresses 81 | ; (IPv6 and IPv4-mapped) on a specific port; 82 | ; '/path/to/unix/socket' - to listen on a unix socket. 83 | ; Note: This value is mandatory. 84 | listen = 127.0.0.1:3000 85 | 86 | 87 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 88 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 89 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 90 | ; must be separated by a comma. If this value is left blank, connections will be 91 | ; accepted from any ip address. 92 | ; Default Value: any 93 | listen.allowed_clients = 127.0.0.1 94 | 95 | 96 | ; Choose how the process manager will control the number of child processes. 97 | ; Possible Values: 98 | ; static - a fixed number (pm.max_children) of child processes; 99 | ; dynamic - the number of child processes are set dynamically based on the 100 | ; following directives. With this process management, there will be 101 | ; always at least 1 children. 102 | ; pm.max_children - the maximum number of children that can 103 | ; be alive at the same time. 104 | ; pm.start_servers - the number of children created on startup. 105 | ; pm.min_spare_servers - the minimum number of children in 'idle' 106 | ; state (waiting to process). If the number 107 | ; of 'idle' processes is less than this 108 | ; number then some children will be created. 109 | ; pm.max_spare_servers - the maximum number of children in 'idle' 110 | ; state (waiting to process). If the number 111 | ; of 'idle' processes is greater than this 112 | ; number then some children will be killed. 113 | ; pm.max_spawn_rate - the maximum number of rate to spawn child 114 | ; processes at once. 115 | ; ondemand - no children are created at startup. Children will be forked when 116 | ; new requests will connect. The following parameter are used: 117 | ; pm.max_children - the maximum number of children that 118 | ; can be alive at the same time. 119 | ; pm.process_idle_timeout - The number of seconds after which 120 | ; an idle process will be killed. 121 | ; Note: This value is mandatory. 122 | pm = static 123 | 124 | ; The number of child processes to be created when pm is set to 'static' and the 125 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 126 | ; This value sets the limit on the number of simultaneous requests that will be 127 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 128 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 129 | ; CGI. The below defaults are based on a server without much resources. Don't 130 | ; forget to tweak pm.* to fit your needs. 131 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 132 | ; Note: This value is mandatory. 133 | ; We only need one child because a lambda can process only one request at a time 134 | pm.max_children = 1 135 | 136 | ; The number of child processes created on startup. 137 | ; Note: Used only when pm is set to 'dynamic' 138 | ; Default Value: (min_spare_servers + max_spare_servers) / 2 139 | pm.start_servers = 1 140 | 141 | ; The desired minimum number of idle server processes. 142 | ; Note: Used only when pm is set to 'dynamic' 143 | ; Note: Mandatory when pm is set to 'dynamic' 144 | pm.min_spare_servers = 1 145 | 146 | ; The desired maximum number of idle server processes. 147 | ; Note: Used only when pm is set to 'dynamic' 148 | ; Note: Mandatory when pm is set to 'dynamic' 149 | pm.max_spare_servers = 1 150 | 151 | ; The number of seconds after which an idle process will be killed. 152 | ; Note: Used only when pm is set to 'ondemand' 153 | ; Default Value: 10s 154 | pm.process_idle_timeout = 10s; 155 | 156 | ; The number of requests each child process should execute before respawning. 157 | ; This can be useful to work around memory leaks in 3rd party libraries. For 158 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 159 | ; Default Value: 0 160 | pm.max_requests = 100000 161 | 162 | ; The access log file 163 | ; Default: not set 164 | access.log = /dev/stdout 165 | 166 | ; The log file for slow requests 167 | ; Default Value: not set 168 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 169 | slowlog = /tmp/www-slow.log 170 | 171 | ; Set max core size rlimit. 172 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 173 | ; Default Value: system defined value 174 | ; Limit the number of core dump logs to 1 to avoid filling up the /tmp disk 175 | rlimit_core = 1 176 | 177 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 178 | ; stderr will be redirected to /dev/null according to FastCGI specs. 179 | ; Note: on highloaded environment, this can cause some delay in the page 180 | ; process time (several ms). 181 | ; Default Value: no 182 | ; Forward stderr of PHP processes to stderr of PHP-FPM (so that it can be sent to cloudwatch) 183 | catch_workers_output = yes 184 | 185 | ; Decorate worker output with prefix and suffix containing information about 186 | ; the child that writes to the log and if stdout or stderr is used as well as 187 | ; log level and time. This options is used only if catch_workers_output is yes. 188 | ; Settings to "no" will output data as written to the stdout or stderr. 189 | ; Default value: yes 190 | ; New PHP 7.3 option that disables a verbose log prefix 191 | decorate_workers_output = no 192 | 193 | ; Clear environment in FPM workers 194 | ; Prevents arbitrary environment variables from reaching FPM worker processes 195 | ; by clearing the environment in workers before env vars specified in this 196 | ; pool configuration are added. 197 | ; Setting to "no" will make all environment variables available to PHP code 198 | ; via getenv(), $_ENV and $_SERVER. 199 | ; Default Value: yes 200 | ; Allows PHP processes to access the lambda's environment variables 201 | clear_env = no 202 | 203 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 204 | ; the current environment. 205 | ; Default Value: clean env 206 | ;env[HOSTNAME] = $HOSTNAME 207 | env[PATH] = /usr/local/bin:/usr/bin:/bin:/opt/php/bin 208 | env[TMP] = /tmp 209 | env[TMPDIR] = /tmp 210 | env[TEMP] = /tmp 211 | 212 | ; Additional php.ini defines, specific to this pool of workers. These settings 213 | ; overwrite the values previously defined in the php.ini. The directives are the 214 | ; same as the PHP SAPI: 215 | ; php_value/php_flag - you can set classic ini defines which can 216 | ; be overwritten from PHP call 'ini_set'. 217 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 218 | ; PHP call 'ini_set' 219 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 220 | 221 | ; Defining 'extension' will load the corresponding shared extension from 222 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 223 | ; overwrite previously defined php.ini values, but will append the new value 224 | ; instead. 225 | 226 | ; Note: path INI options can be relative and will be expanded with the prefix 227 | ; (pool, global or /opt/php) 228 | 229 | ; Default Value: nothing is defined by default except the values in php.ini and 230 | ; specified at startup with the -d argument 231 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 232 | ;php_flag[display_errors] = off 233 | ;php_admin_value[error_log] = /dev/stderr 234 | ;php_admin_flag[log_errors] = on 235 | ;php_admin_value[memory_limit] = 256M 236 | 237 | ; Set the following data paths to directories owned by the FPM process user. 238 | ; 239 | ; Do not change the ownership of existing system directories, if the process 240 | ; user does not have write permission, create dedicated directories for this 241 | ; purpose. 242 | ; 243 | ; See warning about choosing the location of these directories on your system 244 | ; at http://php.net/session.save-path 245 | ;php_value[session.save_handler] = files 246 | ;php_value[session.save_path] = /tmp/session 247 | ;php_value[soap.wsdl_cache_dir] = /tmp/wsdlcache 248 | ;php_value[opcache.file_cache] = /var/lib/php/opcache 249 | 250 | ; New PHP 7.3 option that disables a verbose log prefix 251 | decorate_workers_output = no 252 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2021 Amazon Web Services 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /cdk/lib/laravel-stack.ts: -------------------------------------------------------------------------------- 1 | import { 2 | aws_certificatemanager as acm, 3 | aws_cloudfront as cloudfront, 4 | aws_cloudfront_origins as origins, 5 | aws_ec2 as ec2, 6 | aws_elasticache as elasticache, 7 | aws_lambda as lambda, 8 | aws_rds as rds, 9 | aws_route53 as route53, 10 | aws_route53_targets as route53targets, 11 | aws_s3 as s3, 12 | CfnOutput, 13 | CfnResource, 14 | custom_resources as cr, 15 | Duration, 16 | Lazy, 17 | RemovalPolicy, 18 | Stack, 19 | StackProps, 20 | } from "aws-cdk-lib"; 21 | import {InstanceType} from "aws-cdk-lib/aws-ec2"; 22 | import {Construct} from "constructs"; 23 | import * as path from "path"; 24 | import {S3Origin} from "aws-cdk-lib/aws-cloudfront-origins"; 25 | 26 | export class LaravelStack extends Stack { 27 | constructor(scope: Construct, id: string, props?: StackProps) { 28 | super(scope, id, props); 29 | 30 | // VPC 31 | const lVPC = new ec2.Vpc(this, "vpc", { 32 | maxAzs: 2, 33 | natGateways: 1, 34 | gatewayEndpoints: { 35 | S3: { 36 | service: ec2.GatewayVpcEndpointAwsService.S3, 37 | }, 38 | }, 39 | }); 40 | 41 | // default security group 42 | const lDefaultSecurityGroup = ec2.SecurityGroup.fromSecurityGroupId( 43 | this, 44 | "defaultsg", 45 | lVPC.vpcDefaultSecurityGroup 46 | ); 47 | 48 | // Aurora Mysql Database 49 | const dbClusterInstanceCount: number = 1; 50 | const laravelRds = new rds.DatabaseCluster(this, "Database", { 51 | engine: rds.DatabaseClusterEngine.auroraMysql({ 52 | version: rds.AuroraMysqlEngineVersion.of( 53 | "8.0.mysql_aurora.3.02.0", 54 | "8.0" 55 | ), 56 | }), 57 | credentials: rds.Credentials.fromGeneratedSecret( 58 | this.node.tryGetContext("DB_USER") 59 | ), 60 | defaultDatabaseName: "laravel", 61 | instances: dbClusterInstanceCount, 62 | instanceProps: { 63 | instanceType: new InstanceType("serverless"), 64 | securityGroups: [lDefaultSecurityGroup], 65 | vpc: lVPC, 66 | vpcSubnets: { 67 | subnetType: ec2.SubnetType.PRIVATE_WITH_NAT, 68 | }, 69 | }, 70 | }); 71 | 72 | const serverlessV2ScalingConfiguration = { 73 | MinCapacity: 0.5, 74 | MaxCapacity: 32, 75 | }; 76 | 77 | const dbScalingConfigure = new cr.AwsCustomResource( 78 | this, 79 | "DbScalingConfigure", 80 | { 81 | onCreate: { 82 | service: "RDS", 83 | action: "modifyDBCluster", 84 | parameters: { 85 | DBClusterIdentifier: laravelRds.clusterIdentifier, 86 | ServerlessV2ScalingConfiguration: serverlessV2ScalingConfiguration, 87 | }, 88 | physicalResourceId: cr.PhysicalResourceId.of( 89 | laravelRds.clusterIdentifier 90 | ), 91 | }, 92 | onUpdate: { 93 | service: "RDS", 94 | action: "modifyDBCluster", 95 | parameters: { 96 | DBClusterIdentifier: laravelRds.clusterIdentifier, 97 | ServerlessV2ScalingConfiguration: serverlessV2ScalingConfiguration, 98 | }, 99 | physicalResourceId: cr.PhysicalResourceId.of( 100 | laravelRds.clusterIdentifier 101 | ), 102 | }, 103 | policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ 104 | resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE, 105 | }), 106 | } 107 | ); 108 | 109 | const cfnDbCluster = laravelRds.node.defaultChild as rds.CfnDBCluster; 110 | const dbScalingConfigureTarget = dbScalingConfigure.node.findChild( 111 | "Resource" 112 | ).node.defaultChild as CfnResource; 113 | 114 | cfnDbCluster.addPropertyOverride("EngineMode", "provisioned"); 115 | dbScalingConfigure.node.addDependency(cfnDbCluster); 116 | 117 | for (let i = 1; i <= dbClusterInstanceCount; i++) { 118 | ( 119 | laravelRds.node.findChild(`Instance${i}`) as rds.CfnDBInstance 120 | ).addDependsOn(dbScalingConfigureTarget); 121 | } 122 | 123 | // remove database when the stack is deleted 124 | laravelRds.applyRemovalPolicy(RemovalPolicy.DESTROY); 125 | 126 | // ElastiCache 127 | const lCacheSubnetGroup = new elasticache.CfnSubnetGroup( 128 | this, 129 | "lCacheSubnetGroup", 130 | { 131 | cacheSubnetGroupName: this.stackName + "-lCacheSubnetGroup", 132 | description: "Cache Subnet Group for" + this.stackName, 133 | subnetIds: lVPC.privateSubnets.map((subnet) => subnet.subnetId), 134 | } 135 | ); 136 | 137 | const laravelCache = new elasticache.CfnCacheCluster( 138 | this, 139 | "vwCacheCluster", 140 | { 141 | cacheNodeType: "cache.t3.micro", 142 | engine: "redis", 143 | numCacheNodes: 1, 144 | cacheSubnetGroupName: lCacheSubnetGroup.cacheSubnetGroupName, 145 | vpcSecurityGroupIds: [lDefaultSecurityGroup.securityGroupId], 146 | } 147 | ); 148 | 149 | // remove the redis when the stack is deleted 150 | laravelCache.applyRemovalPolicy(RemovalPolicy.DESTROY); 151 | 152 | laravelCache.addDependsOn(lCacheSubnetGroup); 153 | 154 | // S3 Bucket 155 | const lBucket = new s3.Bucket(this, "bucket", { 156 | removalPolicy: RemovalPolicy.DESTROY, 157 | autoDeleteObjects: true, 158 | blockPublicAccess: { 159 | blockPublicAcls: true, 160 | ignorePublicAcls: true, 161 | blockPublicPolicy: true, 162 | restrictPublicBuckets: true, 163 | } 164 | }); 165 | 166 | const layer = new lambda.LayerVersion(this, 'layer', { 167 | code: lambda.Code.fromAsset(path.join(__dirname, "../layer")), 168 | compatibleRuntimes: [lambda.Runtime.JAVA_11], 169 | license: 'Apache-2.0', 170 | description: 'PHP 7.4', 171 | }); 172 | 173 | // Lambda Function 174 | const laravelFunction = new lambda.Function(this, "laravel", { 175 | functionName: this.stackName + 'Web', 176 | architecture: lambda.Architecture.X86_64, 177 | code: lambda.Code.fromAsset(path.join(__dirname, "../../src/laravel")), 178 | runtime: lambda.Runtime.JAVA_11, 179 | handler: "/opt/bootstrap", 180 | memorySize: 4048, 181 | timeout: Duration.seconds(300), 182 | vpc: lVPC, 183 | vpcSubnets: {subnetType: ec2.SubnetType.PRIVATE_WITH_NAT}, 184 | securityGroups: [lDefaultSecurityGroup], 185 | layers: [layer], 186 | environment: { 187 | LATENCY_VERSION: this.node.tryGetContext("LATENCY_VERSION"), 188 | RUST_LOG: this.node.tryGetContext("RUST_LOG"), 189 | READINESS_CHECK_PATH: this.node.tryGetContext("READINESS_CHECK_PATH"), 190 | AWS_LAMBDA_EXEC_WRAPPER: "/opt/bootstrap", 191 | PRELOAD_DISABLE: this.node.tryGetContext("PRELOAD_DISABLE"), 192 | DB_HOST: laravelRds.secret!.secretValueFromJson("host").toString(), 193 | DB_PORT: laravelRds.secret!.secretValueFromJson("port").toString(), 194 | DB_DATABASE: laravelRds.secret!.secretValueFromJson("dbname").toString(), 195 | DB_USERNAME: laravelRds.secret!.secretValueFromJson("username").toString(), 196 | DB_PASSWORD: laravelRds.secret!.secretValueFromJson("password").toString(), 197 | REDIS_HOST: laravelCache.attrRedisEndpointAddress, 198 | REDIS_PORT: laravelCache.attrRedisEndpointPort, 199 | REDIS_TIMEOUT: "1", 200 | REDIS_READ_TIMEOUT: "1", 201 | REDIS_DATABASE: "0", 202 | FILESYSTEM_DISK: "s3", 203 | AWS_BUCKET: lBucket.bucketName, 204 | LOG_CHANNEL: "stdout", 205 | CACHE_DRIVER: "redis", 206 | SESSION_DRIVER: "redis", 207 | }, 208 | currentVersionOptions: { 209 | removalPolicy: RemovalPolicy.DESTROY, 210 | retryAttempts: 1, 211 | }, 212 | }); 213 | 214 | if (this.node.tryGetContext("SNAPSTART_ENABLE") === 'true') { 215 | (laravelFunction.node.defaultChild as lambda.CfnFunction).addPropertyOverride('SnapStart', { 216 | ApplyOn: 'PublishedVersions', 217 | }); 218 | } 219 | 220 | // Lambda Alias 221 | const liveAlias = laravelFunction.addAlias("live"); 222 | // Add Lambda Function URL to this alias 223 | const fUrl = liveAlias.addFunctionUrl({ 224 | authType: lambda.FunctionUrlAuthType.NONE, 225 | }); 226 | 227 | // Grant Lambda read/write access to the s3 bucket 228 | lBucket.grantReadWrite(laravelFunction); 229 | lBucket.grantPutAcl(laravelFunction); 230 | 231 | // Route53 Domain 232 | const zoneName = this.node.tryGetContext("ROUTE53_HOSTEDZONE"); 233 | if (!zoneName) { 234 | throw new Error(`ROUTE53_HOSTEDZONE not found`); 235 | } 236 | 237 | const lHostedZone = route53.HostedZone.fromLookup(this, "hostedzone", { 238 | domainName: zoneName, 239 | }); 240 | 241 | // ACM Certification 242 | const lDomainName = this.node.tryGetContext("ROUTE53_SITENAME"); 243 | const lCertificate = new acm.DnsValidatedCertificate(this, "certificate", { 244 | domainName: lDomainName, 245 | hostedZone: lHostedZone, 246 | region: "us-east-1", 247 | }); 248 | 249 | // CloudFront 250 | const lDefaultCachePolicy = new cloudfront.CachePolicy( 251 | this, 252 | "lDefaultCachePolicy", 253 | { 254 | cachePolicyName: this.stackName + "-lDefaultCachePolicy", 255 | comment: "default cache policy for " + this.stackName, 256 | defaultTtl: Duration.seconds(0), 257 | minTtl: Duration.seconds(0), 258 | maxTtl: Duration.days(365), 259 | queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(), 260 | headerBehavior: 261 | cloudfront.CacheHeaderBehavior.allowList("Authorization"), 262 | cookieBehavior: cloudfront.CacheCookieBehavior.allowList( 263 | "laravel_*", 264 | ), 265 | enableAcceptEncodingGzip: true, 266 | enableAcceptEncodingBrotli: true, 267 | } 268 | ); 269 | const fUrlOriginRequestPolicy = new cloudfront.OriginRequestPolicy( 270 | this, 271 | "fUrlOriginRequestPolicy", 272 | { 273 | originRequestPolicyName: this.stackName + "-fUrlOriginRequestPolicy", 274 | comment: "api gateway origin request policy for " + this.stackName, 275 | queryStringBehavior: cloudfront.OriginRequestQueryStringBehavior.all(), 276 | headerBehavior: cloudfront.OriginRequestHeaderBehavior.allowList( 277 | "Accept", 278 | "Cache-Control", 279 | "Content-Encoding", 280 | "Content-Type", 281 | "Origin", 282 | "Referer", 283 | "User-Agent", 284 | "X-Forwarded-Host", 285 | ), 286 | cookieBehavior: cloudfront.OriginRequestCookieBehavior.all(), 287 | } 288 | ); 289 | 290 | const lForwardedHostFunction = new cloudfront.Function( 291 | this, 292 | "lForwardedHostFunction", 293 | { 294 | code: cloudfront.FunctionCode.fromInline( 295 | "function handler(event) { \ 296 | var request = event.request; \ 297 | request.headers['x-forwarded-host'] = {value: request.headers.host.value}; \ 298 | return request; \ 299 | }" 300 | ), 301 | } 302 | ); 303 | 304 | const apiDomain = Lazy.uncachedString({ 305 | produce: (context) => { 306 | const resolved = context.resolve(fUrl.url); 307 | return {"Fn::Select": [2, {"Fn::Split": ["/", resolved]}]} as any; 308 | }, 309 | }); 310 | 311 | const lCFDistribution = new cloudfront.Distribution(this, "distribution", { 312 | domainNames: [lDomainName], 313 | certificate: lCertificate, 314 | comment: "Distribution for " + this.stackName, 315 | defaultBehavior: { 316 | origin: new origins.HttpOrigin(apiDomain, { 317 | readTimeout: Duration.seconds(60), 318 | }), 319 | viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, 320 | allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL, 321 | cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS, 322 | cachePolicy: lDefaultCachePolicy, 323 | originRequestPolicy: fUrlOriginRequestPolicy, 324 | compress: true, 325 | functionAssociations: [ 326 | { 327 | function: lForwardedHostFunction, 328 | eventType: cloudfront.FunctionEventType.VIEWER_REQUEST, 329 | }, 330 | ], 331 | }, 332 | additionalBehaviors: { 333 | '/uploads/*': { 334 | origin: new S3Origin(lBucket), 335 | allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS, 336 | cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS, 337 | viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, 338 | }, 339 | }, 340 | }); 341 | 342 | // Route53 record for Cloudfront Distribution 343 | new route53.ARecord(this, "Alias", { 344 | zone: lHostedZone, 345 | recordName: lDomainName, 346 | target: route53.RecordTarget.fromAlias( 347 | new route53targets.CloudFrontTarget(lCFDistribution) 348 | ), 349 | }); 350 | 351 | new CfnOutput(this, "home", { 352 | value: 'https://' + this.node.tryGetContext("ROUTE53_SITENAME"), 353 | }); 354 | 355 | new CfnOutput(this, "lambda_furl", { 356 | value: fUrl.url, 357 | }); 358 | } 359 | } 360 | -------------------------------------------------------------------------------- /src/laravel/resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 |
20 | @if (Route::has('login')) 21 |
22 | @auth 23 | Home 24 | @else 25 | Log in 26 | 27 | @if (Route::has('register')) 28 | Register 29 | @endif 30 | @endauth 31 |
32 | @endif 33 | 34 |
35 |
36 | 37 | 38 | 39 |
40 | 41 | 120 | 121 |
122 | 132 | 133 |
134 | Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}) 135 |
136 |
137 |
138 |
139 | 140 | 141 | --------------------------------------------------------------------------------