Skip to content

Commit

Permalink
WIP: Require Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrig committed Mar 15, 2024
1 parent 998eba9 commit 3838473
Show file tree
Hide file tree
Showing 37 changed files with 336 additions and 899 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -22,5 +22,5 @@ jobs:

- name: Execute tests
run: |
vendor/bin/pint --test
vendor/bin/pint --test -v
vendor/bin/phpunit
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-03-nn

### Added
- Assertion in 'assertGraphqlSent' helper.
- Loading spinner.
Expand Down
24 changes: 24 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 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"

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)
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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-laravel11",
"glesys/butler-auth": "dev-laravel11",
"glesys/butler-graphql": "dev-laravel11",
"glesys/butler-health": "dev-laravel11",
"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,
Expand Down
9 changes: 1 addition & 8 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<?php

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

require __DIR__ . '/../vendor/autoload.php';

$app = require_once __DIR__ . '/../bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = $kernel->handle($request = Request::capture())->send();

$kernel->terminate($request, $response);
(require_once __DIR__ . '/../bootstrap/app.php')->handleRequest(Request::capture());
4 changes: 4 additions & 0 deletions src/Auth/SessionUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
}
30 changes: 0 additions & 30 deletions src/Exceptions/Handler.php

This file was deleted.

44 changes: 42 additions & 2 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,54 @@

namespace Butler\Service\Foundation;

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->shouldRenderJsonWhen(fn (Request $request)
=> $request->expectsJson() || $request->routeIs('graphql')
);
});
}

public function registerConfiguredProviders()
Expand Down
64 changes: 0 additions & 64 deletions src/Http/Kernel.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 0 additions & 29 deletions src/Providers/RouteServiceProvider.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public function boot()

$this->registerMorphMap();

$this->loadCommands();

$this->loadRoutesFrom(__DIR__ . '/routes.php');

$this->loadViewsFrom(__DIR__ . '/../resources/views', 'butler');

$this->loadPublishing();
Expand Down Expand Up @@ -244,15 +240,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()) {
Expand Down
Loading

0 comments on commit 3838473

Please sign in to comment.