From 8adf2307f93223572a8f54af1899fc6eecf46c6c Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 7 Feb 2018 18:26:28 +0100 Subject: [PATCH] Laravel 5.6 Shift (#42) * Shift Middleware * Shift core files * Shift configuration * Shift Laravel dependencies --- .env.example | 8 +++- app/Http/Kernel.php | 1 + app/Http/Middleware/TrustProxies.php | 12 ++--- composer.json | 7 +-- config/broadcasting.php | 3 +- config/cache.php | 5 +- config/filesystems.php | 7 +-- config/hashing.php | 20 ++++++++ config/logging.php | 70 ++++++++++++++++++++++++++++ config/queue.php | 11 +++-- config/session.php | 2 +- 11 files changed, 122 insertions(+), 24 deletions(-) create mode 100644 config/hashing.php create mode 100644 config/logging.php diff --git a/.env.example b/.env.example index 668c06f..ec44a12 100644 --- a/.env.example +++ b/.env.example @@ -2,9 +2,10 @@ APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true -APP_LOG_LEVEL=debug APP_URL=http://localhost +LOG_CHANNEL=stack + DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 @@ -15,6 +16,7 @@ DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file +SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 @@ -31,3 +33,7 @@ MAIL_ENCRYPTION=null PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 93bf68b..74b1cbd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -54,6 +54,7 @@ class Kernel extends HttpKernel 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index ef1c00d..3ce0214 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -15,15 +15,9 @@ class TrustProxies extends Middleware protected $proxies; /** - * The current proxy header mappings. + * The headers that should be used to detect proxies. * - * @var array + * @var string */ - protected $headers = [ - Request::HEADER_FORWARDED => 'FORWARDED', - Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', - Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', - Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', - Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', - ]; + protected $headers = Request::HEADER_X_FORWARDED_ALL; } diff --git a/composer.json b/composer.json index 2c8c61c..854e40c 100644 --- a/composer.json +++ b/composer.json @@ -14,18 +14,19 @@ "botman/driver-web": "~1.0", "botman/studio-addons": "~1.0", "clue/stdio-react": "^1.0", - "laravel/framework": "5.5.*", + "laravel/framework": "5.6.*", "laravel/tinker": "~1.0", "botman/botman": "~2.0", "botman/tinker": "~1.0", "mpociot/slack-client": "^0.3.0", - "fideloper/proxy": "~3.3" + "fideloper/proxy": "~4.0" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~6.0", - "filp/whoops": "~2.0" + "filp/whoops": "~2.0", + "nunomaduro/collision": "~1.1" }, "autoload": { "classmap": [ diff --git a/config/broadcasting.php b/config/broadcasting.php index 5eecd2b..3ca45ea 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,7 +36,8 @@ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - // + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'encrypted' => true, ], ], diff --git a/config/cache.php b/config/cache.php index e87f032..fa12e5e 100644 --- a/config/cache.php +++ b/config/cache.php @@ -86,6 +86,9 @@ | */ - 'prefix' => 'laravel', + 'prefix' => env( + 'CACHE_PREFIX', + str_slug(env('APP_NAME', 'laravel'), '_').'_cache' + ), ]; diff --git a/config/filesystems.php b/config/filesystems.php index 4544f60..67158a5 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -57,10 +57,11 @@ 's3' => [ 'driver' => 's3', - 'key' => env('AWS_KEY'), - 'secret' => env('AWS_SECRET'), - 'region' => env('AWS_REGION'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), ], ], diff --git a/config/hashing.php b/config/hashing.php new file mode 100644 index 0000000..f929cf0 --- /dev/null +++ b/config/hashing.php @@ -0,0 +1,20 @@ + 'bcrypt', + +]; diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000..902efaf --- /dev/null +++ b/config/logging.php @@ -0,0 +1,70 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + 'days' => 7, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => 'critical', + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => 'debug', + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => 'debug', + ], + ], + +]; diff --git a/config/queue.php b/config/queue.php index 4d83ebd..87b1b1b 100644 --- a/config/queue.php +++ b/config/queue.php @@ -50,11 +50,11 @@ 'sqs' => [ 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', - 'queue' => 'your-queue-name', - 'region' => 'us-east-1', + 'key' => env('SQS_KEY', 'your-public-key'), + 'secret' => env('SQS_SECRET', 'your-secret-key'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'your-queue-name'), + 'region' => env('SQS_REGION', 'us-east-1'), ], 'redis' => [ @@ -62,6 +62,7 @@ 'connection' => 'default', 'queue' => 'default', 'retry_after' => 90, + 'block_for' => null, ], ], diff --git a/config/session.php b/config/session.php index 71ad0ed..736fb3c 100644 --- a/config/session.php +++ b/config/session.php @@ -29,7 +29,7 @@ | */ - 'lifetime' => 120, + 'lifetime' => env('SESSION_LIFETIME', 120), 'expire_on_close' => false,