From 9c31a8a879a6f3121dadf68fbbd2305ecf480aab Mon Sep 17 00:00:00 2001 From: markus Date: Thu, 14 Mar 2024 13:29:47 +0100 Subject: [PATCH] WIP: Require Laravel 11 --- .github/workflows/test.yml | 4 +- CHANGELOG.md | 5 + README.md | 9 +- UPGRADE.md | 25 +++ composer.json | 26 +-- config/butler.php | 2 - public/index.php | 9 +- src/Auth/SessionUserProvider.php | 4 + src/Exceptions/Handler.php | 36 ---- src/Foundation/Application.php | 48 ++++- src/Http/Kernel.php | 64 ------ ...ifyCsrfToken.php => ValidateCsrfToken.php} | 4 +- src/Providers/RouteServiceProvider.php | 29 --- src/ServiceProvider.php | 31 --- src/config/app.php | 126 +++-------- src/config/auth.php | 21 +- src/config/cache.php | 19 +- src/config/cors.php | 34 --- src/config/database.php | 25 ++- src/config/filesystems.php | 8 +- src/config/hashing.php | 52 ----- src/config/logging.php | 33 +-- src/config/mail.php | 38 ++-- src/config/queue.php | 51 +++-- src/config/services.php | 34 --- src/config/session.php | 76 ++++--- src/config/view.php | 36 ---- src/routes/api.php | 6 + src/routes/web.php | 34 +++ tests/ServiceProviderTest.php | 20 +- tests/laravel/.env | 4 +- tests/laravel/.env.testing | 4 +- tests/laravel/.gitkeep | 0 tests/laravel/app/Console/Kernel.php | 21 -- .../app/Providers/ExtraServiceProvider.php | 20 -- ...Provider.php => FoobarServiceProvider.php} | 2 +- tests/laravel/artisan | 47 +---- tests/laravel/bootstrap/app.php | 54 +---- tests/laravel/composer.json | 6 +- tests/laravel/config/butler.php | 6 - tests/laravel/config/session.php | 198 +----------------- tests/laravel/public/index.php | 48 +---- 42 files changed, 344 insertions(+), 975 deletions(-) delete mode 100644 src/Exceptions/Handler.php delete mode 100644 src/Http/Kernel.php rename src/Http/Middleware/{VerifyCsrfToken.php => ValidateCsrfToken.php} (67%) delete mode 100644 src/Providers/RouteServiceProvider.php delete mode 100644 src/config/cors.php delete mode 100644 src/config/hashing.php delete mode 100644 src/config/services.php delete mode 100644 src/config/view.php create mode 100644 src/routes/api.php create mode 100644 src/routes/web.php create mode 100644 tests/laravel/.gitkeep delete mode 100644 tests/laravel/app/Console/Kernel.php delete mode 100644 tests/laravel/app/Providers/ExtraServiceProvider.php rename tests/laravel/app/Providers/{AppServiceProvider.php => FoobarServiceProvider.php} (80%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d73a884..6b35026 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [8.1, 8.2] + php: [8.2, 8.3] steps: - uses: actions/checkout@v4 @@ -22,5 +22,5 @@ jobs: - name: Execute tests run: | - vendor/bin/pint --test + vendor/bin/pint --test -v vendor/bin/phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d68aff..7ff4993 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- **BREAKING**: Require Laravel 11 and PHP 8.2. + +## [0.25.1] - 2024-nn-nn + ### Added - Graphql exception `BackendValidation`. - `returnsOnException` method to `Query` test helper class. diff --git a/README.md b/README.md index 8a2c5db..519452e 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,12 @@ php artisan vendor:publish --tag=butler-views ### Extra -If you dont want a `config/app.php` you can use `butler.service.extra` in `config/butler.php` to add "providers", "aliases" and "config". Note that "config" **will not** merge with existing config. +If you dont want a `config/app.php` you can use `butler.service.extra` in `config/butler.php` to add "config". Note that "config" **will not** merge with existing config. ```php // example - 'providers' => [ - Foo\BarServiceProvider::class, - ], - 'aliases' => [ - 'Backend' => App\Facades\Backend::class, - ], 'config' => [ + 'foo' => 'bar', 'trustedproxy.proxies' => [ '10.0.0.0/8', ], diff --git a/UPGRADE.md b/UPGRADE.md index e2793df..fa3ed99 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,28 @@ +## Upgrade from v0.26 to v0.27 + +1. Replace everything in `bootstrap/app.php` with: + +```php +return \Butler\Service\Foundation\Application::configure()->create(); +``` + +1. Copy [public/index.php](https://github.com/laravel/laravel/blob/11.x/public/index.php) +1. Copy [artisan](https://github.com/laravel/laravel/blob/11.x/artisan) + +1. Remove files that are no longer used (use `bootstrap/app.php` instead) + +* `app/Http/Kernel.php` +* `app/Console/Kernel.php` +* `app/Exceptions/Handler.php` + +1. Config changes + +* Use `CACHE_STORE` instead of `CACHE_DRIVER` +* `MAIL_MAILER` now defaults to "log" +* Removed `butler.service.extra.aliases` and `butler.service.extra.providers` + +See https://laravel.com/docs/11.x/upgrade for more information. + ## Upgrade from v0.12 to v0.13 ### BREAKING: Require glesys/butler-audit [v0.4](https://github.com/glesys/butler-audit/blob/master/CHANGELOG.md#040---2021-09-23) diff --git a/composer.json b/composer.json index 932e852..f6caceb 100644 --- a/composer.json +++ b/composer.json @@ -4,26 +4,26 @@ "description": "Web service library based on Laravel", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.2", "bugsnag/bugsnag-laravel": "^2.18", - "glesys/butler-audit": "^0.7", - "glesys/butler-auth": "^6.0", - "glesys/butler-graphql": "^10.0", - "glesys/butler-health": "^0.5.1", + "glesys/butler-audit": "dev-main", + "glesys/butler-auth": "dev-main", + "glesys/butler-graphql": "dev-main", + "glesys/butler-health": "dev-main", "graylog2/gelf-php": "^1.6", "guzzlehttp/guzzle": "^7.2", - "laravel/framework": "^10.9", + "laravel/framework": "^11.0", "laravel/octane": "^1.0 || ^2.0", "laravel/socialite": "^5.5", - "laravel/tinker": "^2.7" + "laravel/tinker": "^2.9" }, "require-dev": { - "fakerphp/faker": "^1.12", - "laravel/pint": "^1.2", - "mockery/mockery": "^1.4.4", - "nunomaduro/collision": "^7.0", - "phpunit/phpunit": "^10.0", - "spatie/laravel-ignition": "^2.0" + "fakerphp/faker": "^1.23.1", + "laravel/pint": "^1.14", + "mockery/mockery": "^1.6.9", + "nunomaduro/collision": "^8.1.1", + "phpunit/phpunit": "^10.5.13", + "spatie/laravel-ignition": "^2.4.2" }, "config": { "optimize-autoloader": true, diff --git a/config/butler.php b/config/butler.php index 3541504..2d04aaf 100644 --- a/config/butler.php +++ b/config/butler.php @@ -35,8 +35,6 @@ 'extra' => [ 'config' => [], - 'aliases' => [], - 'providers' => [], ], ], diff --git a/public/index.php b/public/index.php index 31ea716..283cd99 100644 --- a/public/index.php +++ b/public/index.php @@ -1,16 +1,9 @@ make(Kernel::class); - -$response = $kernel->handle($request = Request::capture())->send(); - -$kernel->terminate($request, $response); +(require_once __DIR__ . '/../bootstrap/app.php')->handleRequest(Request::capture()); diff --git a/src/Auth/SessionUserProvider.php b/src/Auth/SessionUserProvider.php index 57ec0b6..ee4ad54 100644 --- a/src/Auth/SessionUserProvider.php +++ b/src/Auth/SessionUserProvider.php @@ -29,4 +29,8 @@ public function retrieveByCredentials(array $credentials) public function validateCredentials(Authenticatable $user, array $credentials) { } + + public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false) + { + } } diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php deleted file mode 100644 index 74ba4e2..0000000 --- a/src/Exceptions/Handler.php +++ /dev/null @@ -1,36 +0,0 @@ -internalDontReport[] = BackendValidation::class; - } - - /** - * Convert an authentication exception into a response. - * - * @param \Illuminate\Http\Request $request - * @return \Symfony\Component\HttpFoundation\Response - */ - protected function unauthenticated($request, AuthenticationException $exception) - { - return $this->shouldReturnJson($request, $exception) - ? response()->json(['message' => $exception->getMessage()], 401) - : redirect()->guest(route('home')); - } - - protected function shouldReturnJson($request, Throwable $e) - { - return $request->expectsJson() || $request->routeIs('graphql'); - } -} diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index 489397a..98599d6 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -4,14 +4,57 @@ namespace Butler\Service\Foundation; +use Butler\Service\Graphql\Exceptions\BackendValidation; +use Butler\Service\Http\Middleware\Authenticate; +use Butler\Service\Http\Middleware\SetAcceptJson; use Butler\Service\ServiceProvider; use Illuminate\Foundation\Application as BaseApplication; +use Illuminate\Foundation\Configuration\ApplicationBuilder; +use Illuminate\Foundation\Configuration\Exceptions; +use Illuminate\Foundation\Configuration\Middleware; +use Illuminate\Http\Request; class Application extends BaseApplication { - public function configPath($path = '') + public static function configure(?string $basePath = null) { - return realpath(__DIR__ . '/../config') . ($path != '' ? "/$path" : ''); + $basePath = match (true) { + is_string($basePath) => $basePath, + default => static::inferBasePath(), + }; + + $app = (new static($basePath))->useConfigPath(realpath(__DIR__ . '/../config')); + + return (new ApplicationBuilder($app)) + ->withKernels() + ->withEvents() + ->withProviders() + ->withCommands([ + \Butler\Service\Console\Commands\Assets::class, + $app->path('Console/Commands'), + ]) + ->withRouting( + web: $app->basePath('routes/web.php'), + api: $app->basePath('routes/api.php'), + commands: $app->basePath('routes/console.php'), + then: fn () => require __DIR__ . '/../routes.php', + ) + ->withMiddleware(function (Middleware $middleware) { + $middleware + ->redirectGuestsTo('/') + ->validateCsrfTokens(except: ['telescope/*']) + ->alias([ + 'auth' => Authenticate::class, + 'set-accept-json' => SetAcceptJson::class, + ]); + }) + ->withExceptions(function (Exceptions $exceptions) { + $exceptions + ->dontReport(BackendValidation::class) + ->shouldRenderJsonWhen(fn (Request $request) + => $request->expectsJson() || $request->routeIs('graphql') + ); + }); } public function registerConfiguredProviders() @@ -21,6 +64,5 @@ public function registerConfiguredProviders() parent::registerConfiguredProviders(); $butlerService->registerApplicationProviders(); - $butlerService->registerExtraProviders(); } } diff --git a/src/Http/Kernel.php b/src/Http/Kernel.php deleted file mode 100644 index 60100d1..0000000 --- a/src/Http/Kernel.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ - protected $middleware = [ - \Illuminate\Http\Middleware\TrustProxies::class, - \Illuminate\Http\Middleware\HandleCors::class, - \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, - \Illuminate\Foundation\Http\Middleware\TrimStrings::class, - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, - ]; - - /** - * The application's route middleware groups. - * - * @var array> - */ - protected $middlewareGroups = [ - 'web' => [ - \Illuminate\Cookie\Middleware\EncryptCookies::class, - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \Butler\Service\Http\Middleware\VerifyCsrfToken::class, - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - - 'api' => [ - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - ]; - - /** - * The application's middleware aliases. - * - * Aliases may be used to conveniently assign middleware to routes and groups. - * - * @var array - */ - protected $middlewareAliases = [ - 'auth' => \Butler\Service\Http\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, - 'set-accept-json' => \Butler\Service\Http\Middleware\SetAcceptJson::class, - ]; -} diff --git a/src/Http/Middleware/VerifyCsrfToken.php b/src/Http/Middleware/ValidateCsrfToken.php similarity index 67% rename from src/Http/Middleware/VerifyCsrfToken.php rename to src/Http/Middleware/ValidateCsrfToken.php index 3478801..1b45b19 100644 --- a/src/Http/Middleware/VerifyCsrfToken.php +++ b/src/Http/Middleware/ValidateCsrfToken.php @@ -4,9 +4,9 @@ namespace Butler\Service\Http\Middleware; -use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; +use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken as Middleware; -class VerifyCsrfToken extends Middleware +class ValidateCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. diff --git a/src/Providers/RouteServiceProvider.php b/src/Providers/RouteServiceProvider.php deleted file mode 100644 index 866a990..0000000 --- a/src/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,29 +0,0 @@ -routes(function () { - if (is_file($apiRoutes = base_path('routes/api.php'))) { - Route::middleware('api')->group($apiRoutes); - } - - if (is_file($webRoutes = base_path('routes/web.php'))) { - Route::middleware('web')->group($webRoutes); - } - }); - } -} diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index c6a2df5..044d474 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -40,8 +40,6 @@ public function register() $this->configureHealth(); $this->registerBaseProviders(); - - $this->registerExtraAliases(); } public function boot() @@ -50,10 +48,6 @@ public function boot() $this->registerMorphMap(); - $this->loadCommands(); - - $this->loadRoutesFrom(__DIR__ . '/routes.php'); - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'butler'); $this->loadPublishing(); @@ -198,22 +192,6 @@ public function registerApplicationProviders() } } - public function registerExtraProviders() - { - foreach (config('butler.service.extra.providers', []) as $provider) { - $this->app->register($provider); - } - } - - protected function registerExtraAliases() - { - $this->app->booting(function () { - foreach (config('butler.service.extra.aliases', []) as $key => $alias) { - \Illuminate\Foundation\AliasLoader::getInstance()->alias($key, $alias); - } - }); - } - protected function loadMigrations() { if ($this->app->runningInConsole()) { @@ -232,15 +210,6 @@ protected function registerMorphMap() ]); } - protected function loadCommands() - { - if ($this->app->runningInConsole()) { - $this->commands([ - \Butler\Service\Console\Commands\Assets::class, - ]); - } - } - protected function loadPublishing() { if ($this->app->runningInConsole()) { diff --git a/src/config/app.php b/src/config/app.php index 4159196..f467267 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -1,7 +1,5 @@ env('APP_NAME', 'butler-service'), + 'name' => env('APP_NAME', 'Laravel'), /* |-------------------------------------------------------------------------- @@ -50,26 +48,24 @@ | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. + | the application so that it's available within Artisan commands. | */ 'url' => env('APP_URL', 'http://localhost'), - 'asset_url' => env('ASSET_URL'), - /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. + | will be used by the PHP date and date-time functions. The timezone + | is set to "UTC" by default as it is suitable for most use cases. | */ - 'timezone' => 'UTC', + 'timezone' => env('APP_TIMEZONE', 'UTC'), /* |-------------------------------------------------------------------------- @@ -77,116 +73,54 @@ |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. + | by Laravel's translation / localization methods. This option can be + | set to any locale for which you plan to have translation strings. | */ - 'fallback_locale' => 'en', + 'locale' => env('APP_LOCALE', 'en'), - /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | - */ + 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), - 'faker_locale' => 'en_US', + 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! + | This key is utilized by Laravel's encryption services and should be set + | to a random, 32 character string to ensure that all encrypted values + | are secure. You should do this prior to deploying the application. | */ - 'key' => env('APP_KEY'), - 'cipher' => 'AES-256-CBC', - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - - 'providers' => [ - - /* - * Laravel Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - Illuminate\Foundation\Providers\FoundationServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ - Butler\Service\Providers\RouteServiceProvider::class, + 'key' => env('APP_KEY'), + 'previous_keys' => [ + ...array_filter( + explode(',', env('APP_PREVIOUS_KEYS', '')) + ), ], /* |-------------------------------------------------------------------------- - | Class Aliases + | Maintenance Mode Driver |-------------------------------------------------------------------------- | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. + | These configuration options determine the driver used to determine and + | manage Laravel's "maintenance mode" status. The "cache" driver will + | allow maintenance mode to be controlled across multiple machines. + | + | Supported drivers: "file", "cache" | */ - 'aliases' => Facade::defaultAliases()->merge([ - // ... - ])->toArray(), + 'maintenance' => [ + 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), + 'store' => env('APP_MAINTENANCE_STORE', 'database'), + ], ]; diff --git a/src/config/auth.php b/src/config/auth.php index 62551c3..74333aa 100644 --- a/src/config/auth.php +++ b/src/config/auth.php @@ -7,14 +7,15 @@ | Authentication Defaults |-------------------------------------------------------------------------- | - | This option controls the default authentication "guard" and password - | reset options for your application. You may change these defaults + | This option defines the default authentication "guard" and password + | reset "broker" for your application. You may change these values | as required, but they're a perfect start for most applications. | */ 'defaults' => [ - 'guard' => 'web', + 'guard' => env('AUTH_GUARD', 'web'), + 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), ], /* @@ -24,11 +25,11 @@ | | Next, you may define every authentication guard for your application. | Of course, a great default configuration has been defined for you - | here which uses session storage and the Eloquent user provider. + | which utilizes session storage plus the Eloquent user provider. | - | All authentication drivers have a user provider. This defines how the + | All authentication guards have a user provider, which defines how the | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. + | system used by the application. Typically, Eloquent is utilized. | | Supported: "session" | @@ -50,12 +51,12 @@ | User Providers |-------------------------------------------------------------------------- | - | All authentication drivers have a user provider. This defines how the + | All authentication guards have a user provider, which defines how the | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. + | system used by the application. Typically, Eloquent is utilized. | | If you have multiple user tables or models you may configure multiple - | sources which represent each model / table. These sources may then + | providers to represent the model / table. These providers may then | be assigned to any extra authentication guards you have defined. | | Supported: "database", "eloquent" @@ -68,7 +69,7 @@ ], 'consumers' => [ 'driver' => 'eloquent', - 'model' => Butler\Service\Models\Consumer::class, + 'model' => env('AUTH_MODEL', Butler\Service\Models\Consumer::class), ], ], diff --git a/src/config/cache.php b/src/config/cache.php index 020fde0..1b7359c 100644 --- a/src/config/cache.php +++ b/src/config/cache.php @@ -9,13 +9,13 @@ | Default Cache Store |-------------------------------------------------------------------------- | - | This option controls the default cache connection that gets used while - | using this caching library. This connection is used when another is - | not explicitly specified when executing a given caching function. + | This option controls the default cache store that will be used by the + | framework. This connection is utilized if another isn't explicitly + | specified when running a cache operation inside the application. | */ - 'default' => env('CACHE_DRIVER', 'file'), + 'default' => env('CACHE_STORE', 'file'), /* |-------------------------------------------------------------------------- @@ -26,8 +26,8 @@ | well as their drivers. You may even define multiple stores for the | same cache driver to group types of items stored in your caches. | - | Supported drivers: "apc", "array", "database", "file", - | "memcached", "redis", "dynamodb", "octane", "null" + | Supported drivers: "apc", "array", "database", "file", "memcached", + | "redis", "dynamodb", "octane", "null" | */ @@ -45,7 +45,8 @@ 'redis' => [ 'driver' => 'redis', - 'connection' => 'cache', + 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), + 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), ], 'octane' => [ @@ -59,8 +60,8 @@ | Cache Key Prefix |-------------------------------------------------------------------------- | - | When utilizing the APC, database, memcached, Redis, or DynamoDB cache - | stores there might be other applications using the same cache. For + | When utilizing the APC, database, memcached, Redis, and DynamoDB cache + | stores, there might be other applications using the same cache. For | that reason, you may prefix every cache key to avoid collisions. | */ diff --git a/src/config/cors.php b/src/config/cors.php deleted file mode 100644 index 8a39e6d..0000000 --- a/src/config/cors.php +++ /dev/null @@ -1,34 +0,0 @@ - ['api/*', 'sanctum/csrf-cookie'], - - 'allowed_methods' => ['*'], - - 'allowed_origins' => ['*'], - - 'allowed_origins_patterns' => [], - - 'allowed_headers' => ['*'], - - 'exposed_headers' => [], - - 'max_age' => 0, - - 'supports_credentials' => false, - -]; diff --git a/src/config/database.php b/src/config/database.php index 95b4468..5935b41 100644 --- a/src/config/database.php +++ b/src/config/database.php @@ -10,8 +10,9 @@ |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. + | to use as your default connection for database operations. This is + | the connection which will be utilized unless another connection + | is explicitly specified when you execute a query / statement. | */ @@ -22,14 +23,9 @@ | Database Connections |-------------------------------------------------------------------------- | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. + | Below are all of the database connections defined for your application. + | An example configuration is provided for each database system which + | is supported by Laravel. You're free to add / remove connections. | */ @@ -65,11 +61,14 @@ | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. + | the migrations on disk haven't actually been run on the database. | */ - 'migrations' => 'migrations', + 'migrations' => [ + 'table' => 'migrations', + 'update_date_on_publish' => true, + ], /* |-------------------------------------------------------------------------- @@ -78,7 +77,7 @@ | | Redis is an open source, fast, and advanced key-value store that also | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. + | such as Memcached. You may define your connection settings here. | */ diff --git a/src/config/filesystems.php b/src/config/filesystems.php index 4afc1fc..40b7e78 100644 --- a/src/config/filesystems.php +++ b/src/config/filesystems.php @@ -9,7 +9,7 @@ | | Here you may specify the default filesystem disk that should be used | by the framework. The "local" disk, as well as a variety of cloud - | based disks are available to your application. Just store away! + | based disks are available to your application for file storage. | */ @@ -20,9 +20,9 @@ | Filesystem Disks |-------------------------------------------------------------------------- | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been set up for each driver as an example of the required values. + | Below you may configure as many filesystem disks as necessary, and you + | may even configure multiple disks for the same driver. Examples for + | most supported storage drivers are configured here for reference. | | Supported Drivers: "local", "ftp", "sftp", "s3" | diff --git a/src/config/hashing.php b/src/config/hashing.php deleted file mode 100644 index bcd3be4..0000000 --- a/src/config/hashing.php +++ /dev/null @@ -1,52 +0,0 @@ - 'bcrypt', - - /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'bcrypt' => [ - 'rounds' => env('BCRYPT_ROUNDS', 10), - ], - - /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'argon' => [ - 'memory' => 65536, - 'threads' => 1, - 'time' => 4, - ], - -]; diff --git a/src/config/logging.php b/src/config/logging.php index 2cbb6e7..5a5b0f9 100644 --- a/src/config/logging.php +++ b/src/config/logging.php @@ -3,6 +3,7 @@ use Butler\Service\Logging\GraylogLoggerFactory; use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; +use Monolog\Processor\PsrLogMessageProcessor; return [ @@ -11,9 +12,9 @@ | Default Log Channel |-------------------------------------------------------------------------- | - | This option defines the default log channel that gets used when writing - | messages to the logs. The name specified in this option should match - | one of the channels defined in the "channels" configuration array. + | This option defines the default log channel that is utilized to write + | messages to your logs. The value provided here should match one of + | the channels present in the list of "channels" configured below. | */ @@ -32,7 +33,7 @@ 'deprecations' => [ 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, + 'trace' => env('LOG_DEPRECATIONS_TRACE', false), ], /* @@ -40,17 +41,17 @@ | 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. + | Here you may configure the log channels for your application. Laravel + | utilizes the Monolog PHP logging library, which includes a variety + | of powerful log handlers and formatters that you're free to use. | | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" + | "errorlog", "monolog", "custom", "stack" | */ 'channels' => [ + 'stack' => [ 'driver' => 'stack', 'channels' => array_filter([ @@ -65,21 +66,24 @@ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, + 'days' => env('LOG_DAILY_DAYS', 14), + 'replace_placeholders' => true, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', + 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), + 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 'level' => env('LOG_LEVEL', 'critical'), + 'replace_placeholders' => true, ], 'stderr' => [ @@ -90,17 +94,20 @@ 'with' => [ 'stream' => 'php://stderr', ], + 'processors' => [PsrLogMessageProcessor::class], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), - 'facility' => LOG_USER, + 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), + 'replace_placeholders' => true, ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'null' => [ diff --git a/src/config/mail.php b/src/config/mail.php index 542d98c..634ee8a 100644 --- a/src/config/mail.php +++ b/src/config/mail.php @@ -7,13 +7,14 @@ | Default Mailer |-------------------------------------------------------------------------- | - | This option controls the default mailer that is used to send any email - | messages sent by your application. Alternative mailers may be setup - | and used as needed; however, this mailer will be used by default. + | This option controls the default mailer that is used to send all email + | messages unless another mailer is explicitly specified when sending + | the message. All additional mailers can be configured within the + | "mailers" array. Examples of each type of mailer are provided. | */ - 'default' => env('MAIL_MAILER', 'smtp'), + 'default' => env('MAIL_MAILER', 'log'), /* |-------------------------------------------------------------------------- @@ -24,20 +25,22 @@ | their respective settings. Several examples have been configured for | you and you are free to add your own as your application requires. | - | Laravel supports a variety of mail "transport" drivers to be used while - | sending an e-mail. You will specify which one you are using for your - | mailers below. You are free to add additional mailers as required. + | Laravel supports a variety of mail "transport" drivers that can be used + | when delivering an email. You may specify which one you're using for + | your mailers below. You may also add additional mailers if needed. | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", - | "postmark", "log", "array", "failover" + | "postmark", "log", "array", "failover", "roundrobin" | */ 'mailers' => [ + 'smtp' => [ 'transport' => 'smtp', - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'port' => env('MAIL_PORT', 587), + 'url' => env('MAIL_URL'), + 'host' => env('MAIL_HOST', '127.0.0.1'), + 'port' => env('MAIL_PORT', 2525), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), @@ -49,15 +52,9 @@ 'transport' => 'ses', ], - 'mailgun' => [ - 'transport' => 'mailgun', - // 'client' => [ - // 'timeout' => 5, - // ], - ], - 'postmark' => [ 'transport' => 'postmark', + // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), // 'client' => [ // 'timeout' => 5, // ], @@ -84,6 +81,7 @@ 'log', ], ], + ], /* @@ -91,9 +89,9 @@ | Global "From" Address |-------------------------------------------------------------------------- | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. + | You may wish for all emails sent by your application to be sent from + | the same address. Here you may specify a name and address that is + | used globally for all emails that are sent by your application. | */ diff --git a/src/config/queue.php b/src/config/queue.php index 54c9c9f..07d86f6 100644 --- a/src/config/queue.php +++ b/src/config/queue.php @@ -7,9 +7,9 @@ | Default Queue Connection Name |-------------------------------------------------------------------------- | - | Laravel's queue API supports an assortment of back-ends via a single - | API, giving you convenient access to each back-end using the same - | syntax for every one. Here you may define a default connection. + | Laravel's queue supports a variety of backends via a single, unified + | API, giving you convenient access to each backend using identical + | syntax for each. The default queue connection is defined below. | */ @@ -20,9 +20,9 @@ | Queue Connections |-------------------------------------------------------------------------- | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. + | Here you may configure the connection options for every queue backend + | used by your application. An example configuration is provided for + | each backend supported by Laravel. You're also free to add more. | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | @@ -36,17 +36,18 @@ 'database' => [ 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, + 'connection' => env('DB_QUEUE_CONNECTION', null), + 'table' => env('DB_QUEUE_TABLE', 'jobs'), + 'queue' => env('DB_QUEUE', 'default'), + 'retry_after' => env('DB_QUEUE_RETRY_AFTER', 90), 'after_commit' => false, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), + 'queue' => env('BEANSTALKD_QUEUE', 'default'), + 'retry_after' => env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 'block_for' => 0, 'after_commit' => false, ], @@ -64,23 +65,41 @@ 'redis' => [ 'driver' => 'redis', - 'connection' => 'default', + 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'retry_after' => env('REDIS_QUEUE_RETRY_AFTER', 90), 'block_for' => null, 'after_commit' => false, ], ], + /* + |-------------------------------------------------------------------------- + | Job Batching + |-------------------------------------------------------------------------- + | + | The following options configure the database and table that store job + | batching information. These options can be updated to any database + | connection and table which has been defined by your application. + | + */ + + 'batching' => [ + 'database' => env('DB_CONNECTION', 'sqlite'), + 'table' => 'job_batches', + ], + /* |-------------------------------------------------------------------------- | Failed Queue Jobs |-------------------------------------------------------------------------- | | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. + | can control how and where failed jobs are stored. Laravel ships with + | support for storing failed jobs in a simple file or in a database. + | + | Supported drivers: "database-uuids", "dynamodb", "file", "null" | */ diff --git a/src/config/services.php b/src/config/services.php deleted file mode 100644 index 0ace530..0000000 --- a/src/config/services.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - 'domain' => env('MAILGUN_DOMAIN'), - 'secret' => env('MAILGUN_SECRET'), - 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'scheme' => 'https', - ], - - 'postmark' => [ - 'token' => env('POSTMARK_TOKEN'), - ], - - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - ], - -]; diff --git a/src/config/session.php b/src/config/session.php index 1b99f22..82fe57b 100644 --- a/src/config/session.php +++ b/src/config/session.php @@ -9,9 +9,9 @@ | Default Session Driver |-------------------------------------------------------------------------- | - | This option controls the default session "driver" that will be used on - | requests. By default, we will use the lightweight native driver but - | you may specify any of the other wonderful drivers provided here. + | This option determines the default session driver that is utilized for + | incoming requests. Laravel supports a variety of storage options to + | persist session data. Database storage is a great default choice. | | Supported: "file", "cookie", "database", "apc", | "memcached", "redis", "dynamodb", "array" @@ -27,13 +27,14 @@ | | Here you may specify the number of minutes that you wish the session | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. + | to expire immediately when the browser is closed then you may + | indicate that via the expire_on_close configuration option. | */ 'lifetime' => env('SESSION_LIFETIME', 120), - 'expire_on_close' => false, + 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), /* |-------------------------------------------------------------------------- @@ -41,21 +42,21 @@ |-------------------------------------------------------------------------- | | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. + | should be encrypted before it's stored. All encryption is performed + | automatically by Laravel and you may use the session like normal. | */ - 'encrypt' => false, + 'encrypt' => env('SESSION_ENCRYPT', false), /* |-------------------------------------------------------------------------- | Session File Location |-------------------------------------------------------------------------- | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. + | When utilizing the "file" session driver, the session files are placed + | on disk. The default storage location is defined here; however, you + | are free to provide another location where they should be stored. | */ @@ -79,22 +80,22 @@ | Session Database Table |-------------------------------------------------------------------------- | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. + | When using the "database" session driver, you may specify the table to + | be used to store sessions. Of course, a sensible default is defined + | for you; however, you're welcome to change this to another table. | */ - 'table' => 'sessions', + 'table' => env('SESSION_TABLE', 'sessions'), /* |-------------------------------------------------------------------------- | Session Cache Store |-------------------------------------------------------------------------- | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". + | When using one of the framework's cache driven session backends, you may + | define the cache store which should be used to store the session data + | between requests. This must match one of your defined cache stores. | | Affects: "apc", "dynamodb", "memcached", "redis" | @@ -120,9 +121,9 @@ | Session Cookie Name |-------------------------------------------------------------------------- | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. + | Here you may change the name of the session cookie that is created by + | the framework. Typically, you should not need to change this value + | since doing so does not grant a meaningful security improvement. | */ @@ -138,20 +139,20 @@ | | The session cookie path determines the path for which the cookie will | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. + | your application, but you're free to change this when necessary. | */ - 'path' => '/', + 'path' => env('SESSION_PATH', '/'), /* |-------------------------------------------------------------------------- | Session Cookie Domain |-------------------------------------------------------------------------- | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. + | This value determines the domain and subdomains the session cookie is + | available to. By default, the cookie will be available to the root + | domain and all subdomains. Typically, this shouldn't be changed. | */ @@ -177,11 +178,11 @@ | | Setting this value to true will prevent JavaScript from accessing the | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. + | the HTTP protocol. It's unlikely you should disable this option. | */ - 'http_only' => true, + 'http_only' => env('SESSION_HTTP_ONLY', true), /* |-------------------------------------------------------------------------- @@ -190,12 +191,27 @@ | | This option determines how your cookies behave when cross-site requests | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. + | will set this value to "lax" to permit secure cross-site requests. + | + | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value | | Supported: "lax", "strict", "none", null | */ - 'same_site' => 'lax', + 'same_site' => env('SESSION_SAME_SITE', 'lax'), + + /* + |-------------------------------------------------------------------------- + | Partitioned Cookies + |-------------------------------------------------------------------------- + | + | Setting this value to true will tie the cookie to the top-level site for + | a cross-site context. Partitioned cookies are accepted by the browser + | when flagged "secure" and the Same-Site attribute is set to "none". + | + */ + + 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), ]; diff --git a/src/config/view.php b/src/config/view.php deleted file mode 100644 index 22b8a18..0000000 --- a/src/config/view.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - resource_path('views'), - ], - - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | - */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - -]; diff --git a/src/routes/api.php b/src/routes/api.php new file mode 100644 index 0000000..49cd5cf --- /dev/null +++ b/src/routes/api.php @@ -0,0 +1,6 @@ +name('graphql'); diff --git a/src/routes/web.php b/src/routes/web.php new file mode 100644 index 0000000..a12dca9 --- /dev/null +++ b/src/routes/web.php @@ -0,0 +1,34 @@ +name('home'); +Route::get('/health', config('butler.service.controllers.health', HealthController::class))->name('health'); +Route::get('/about', config('butler.service.controllers.about', AboutController::class))->name('about'); + +Route::controller(config('butler.service.controllers.failed_jobs', FailedJobsController::class))->group(function () { + Route::get('failed-jobs', 'index')->name('failed-jobs.index'); + Route::get('failed-jobs/{id}', 'show')->name('failed-jobs.show'); + Route::post('failed-jobs/retry', 'retry')->name('failed-jobs.retry'); + Route::post('failed-jobs/forget', 'forget')->name('failed-jobs.forget'); +}); + +Route::controller(config('butler.service.controllers.tokens', TokensController::class))->group(function () { + Route::get('tokens', 'index')->name('tokens.index'); + Route::post('tokens', 'store')->name('tokens.store'); + Route::delete('tokens', 'destroy')->name('tokens.delete'); +}); + +if (config('butler.sso.enabled')) { + Route::prefix('auth')->controller(config('butler.service.controllers.auth', AuthController::class))->group(function () { + Route::get('redirect', 'redirect')->name('auth.redirect'); + Route::get('callback', 'callback')->name('auth.callback'); + Route::post('logout', 'logout')->name('auth.logout'); + }); +} diff --git a/tests/ServiceProviderTest.php b/tests/ServiceProviderTest.php index 674d657..78b19cd 100644 --- a/tests/ServiceProviderTest.php +++ b/tests/ServiceProviderTest.php @@ -49,7 +49,8 @@ public function test_mergeApplicationConfig_merges_source_and_application_config public function test_application_config_files_is_merged() { - $this->assertEquals('test-dummy-value', config('session.table')); + $this->assertEquals('sessions', config('session.table')); + $this->assertEquals('baz', config('session.foobar')); } public function test_extra_config_is_configured() @@ -60,24 +61,11 @@ public function test_extra_config_is_configured() public function test_application_providers_are_registered() { $this->assertInstanceOf( - \App\Providers\AppServiceProvider::class, - app()->getProvider(\App\Providers\AppServiceProvider::class) + \App\Providers\FoobarServiceProvider::class, + app()->getProvider(\App\Providers\FoobarServiceProvider::class) ); } - public function test_extra_providers_are_registered() - { - $this->assertInstanceOf( - \App\Providers\ExtraServiceProvider::class, - app()->getProvider(\App\Providers\ExtraServiceProvider::class) - ); - } - - public function test_extra_aliases_are_registered() - { - $this->assertInstanceOf(Cache::class, app('Foobar')); - } - public function test_migration_paths_are_loaded() { $paths = app('migrator')->paths(); diff --git a/tests/laravel/.env b/tests/laravel/.env index 54c861b..d990fe1 100644 --- a/tests/laravel/.env +++ b/tests/laravel/.env @@ -1,4 +1,4 @@ -APP_NAME=Laravel +APP_NAME="Butler Service Laravel" APP_ENV=local APP_KEY=AckfSECXIvnK5r28GVIWUAxmbBSjTsmF APP_DEBUG=true @@ -12,7 +12,7 @@ DB_DRIVER=sqlite DB_DATABASE=default.sqlite BROADCAST_DRIVER=log -CACHE_DRIVER=file +CACHE_STORE=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync SESSION_DRIVER=file diff --git a/tests/laravel/.env.testing b/tests/laravel/.env.testing index bfdb384..b216216 100644 --- a/tests/laravel/.env.testing +++ b/tests/laravel/.env.testing @@ -1,4 +1,4 @@ -APP_NAME=Laravel +APP_NAME="Butler Service Laravel" APP_ENV=testing APP_KEY=AckfSECXIvnK5r28GVIWUAxmbBSjTsmF APP_DEBUG=false @@ -14,7 +14,7 @@ DB_DRIVER=sqlite DB_DATABASE=:memory: BROADCAST_DRIVER=log -CACHE_DRIVER=array +CACHE_STORE=array FILESYSTEM_DISK=local QUEUE_CONNECTION=sync SESSION_DRIVER=array diff --git a/tests/laravel/.gitkeep b/tests/laravel/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/laravel/app/Console/Kernel.php b/tests/laravel/app/Console/Kernel.php deleted file mode 100644 index 329fb0e..0000000 --- a/tests/laravel/app/Console/Kernel.php +++ /dev/null @@ -1,21 +0,0 @@ -load(__DIR__ . '/Commands'); - } -} diff --git a/tests/laravel/app/Providers/ExtraServiceProvider.php b/tests/laravel/app/Providers/ExtraServiceProvider.php deleted file mode 100644 index 4aed690..0000000 --- a/tests/laravel/app/Providers/ExtraServiceProvider.php +++ /dev/null @@ -1,20 +0,0 @@ -make(Illuminate\Contracts\Console\Kernel::class); - -$status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput, - new Symfony\Component\Console\Output\ConsoleOutput -); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running, we will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$kernel->terminate($input, $status); +$status = (require_once __DIR__ . '/bootstrap/app.php')->handleCommand(new ArgvInput); exit($status); diff --git a/tests/laravel/bootstrap/app.php b/tests/laravel/bootstrap/app.php index ae8c1ee..25fae95 100644 --- a/tests/laravel/bootstrap/app.php +++ b/tests/laravel/bootstrap/app.php @@ -1,55 +1,5 @@ singleton( - Illuminate\Contracts\Http\Kernel::class, - App\Http\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - App\Console\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - App\Exceptions\Handler::class -); - -/* -|-------------------------------------------------------------------------- -| Return The Application -|-------------------------------------------------------------------------- -| -| This script returns the application instance. The instance is given to -| the calling script so we can separate the building of the instances -| from the actual running of the application and sending responses. -| -*/ - -return $app; +return Application::configure(dirname(__DIR__))->create(); diff --git a/tests/laravel/composer.json b/tests/laravel/composer.json index d944e14..633e7b6 100644 --- a/tests/laravel/composer.json +++ b/tests/laravel/composer.json @@ -2,11 +2,11 @@ "name": "laravel/laravel", "type": "project", "require": { - "php": "^8.1", - "glesys/butler-service": "^0.22.1" + "php": "^8.2", + "glesys/butler-service": "^0.26" }, "require-dev": { - "phpunit/phpunit": "^10.1.1" + "phpunit/phpunit": "^10.5" }, "autoload": { "psr-4": { diff --git a/tests/laravel/config/butler.php b/tests/laravel/config/butler.php index 1c0e30f..3cab073 100644 --- a/tests/laravel/config/butler.php +++ b/tests/laravel/config/butler.php @@ -17,12 +17,6 @@ 'app.timezone' => 'Europe/Stockholm', 'foo' => 'bar', ], - 'aliases' => [ - 'Foobar' => Illuminate\Support\Facades\Cache::class, - ], - 'providers' => [ - App\Providers\ExtraServiceProvider::class, - ], ], ], diff --git a/tests/laravel/config/session.php b/tests/laravel/config/session.php index bf39227..b1985e6 100644 --- a/tests/laravel/config/session.php +++ b/tests/laravel/config/session.php @@ -1,201 +1,5 @@ env('SESSION_DRIVER', 'file'), - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ - - 'lifetime' => env('SESSION_LIFETIME', 120), - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | - */ - - 'encrypt' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path('framework/sessions'), - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ - - 'connection' => env('SESSION_CONNECTION'), - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'test-dummy-value', - - /* - |-------------------------------------------------------------------------- - | Session Cache Store - |-------------------------------------------------------------------------- - | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". - | - | Affects: "apc", "dynamodb", "memcached", "redis" - | - */ - - 'store' => env('SESSION_STORE'), - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => [2, 100], - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => env( - 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' - ), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => env('SESSION_DOMAIN'), - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you when it can't be done securely. - | - */ - - 'secure' => env('SESSION_SECURE_COOKIE'), - - /* - |-------------------------------------------------------------------------- - | HTTP Access Only - |-------------------------------------------------------------------------- - | - | Setting this value to true will prevent JavaScript from accessing the - | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. - | - */ - - 'http_only' => true, - - /* - |-------------------------------------------------------------------------- - | Same-Site Cookies - |-------------------------------------------------------------------------- - | - | This option determines how your cookies behave when cross-site requests - | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. - | - | Supported: "lax", "strict", "none", null - | - */ - - 'same_site' => 'lax', - + 'foobar' => 'baz', ]; diff --git a/tests/laravel/public/index.php b/tests/laravel/public/index.php index d4d5c36..54ced83 100644 --- a/tests/laravel/public/index.php +++ b/tests/laravel/public/index.php @@ -1,55 +1,9 @@ make(Kernel::class); - -$response = $kernel->handle( - $request = Request::capture() -)->send(); - -$kernel->terminate($request, $response); +(require_once __DIR__ . '/../bootstrap/app.php')->handleRequest(Request::capture());