Skip to content

Commit

Permalink
Require Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrig committed May 31, 2024
1 parent 7f08d7d commit 51fb737
Show file tree
Hide file tree
Showing 42 changed files with 358 additions and 981 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Graphql exception `BackendValidation`.
- `returnsOnException` method to `Query` test helper class.

### Changed
- **BREAKING**: Require Laravel 11 and PHP 8.2.

## [0.26.0] - 2024-04-04

### Added
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
34 changes: 34 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
## Upgrade from v0.26 to v0.27

### Update `bootstrap/app.php`

Replace everything with:

```php
return Butler\Service\Foundation\Application::configure()->create();
```

### Copy files

1. [public/index.php](https://github.com/laravel/laravel/blob/11.x/public/index.php)
1. [artisan](https://github.com/laravel/laravel/blob/11.x/artisan)

### Remove files

*Use `bootstrap/app.php` instead*

* `app/Http/Kernel.php`
* `app/Console/Kernel.php`
* `app/Exceptions/Handler.php`

### 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`

### Additional breaking changes

* [butler-health](https://github.com/glesys/butler-health/blob/main/CHANGELOG.md#060---2024-05-28)
* [laravel](https://laravel.com/docs/11.x/upgrade)

## 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": "^0.8",
"glesys/butler-auth": "^7.0",
"glesys/butler-graphql": "^11.0",
"glesys/butler-health": "^0.6",
"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
2 changes: 0 additions & 2 deletions config/butler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

'extra' => [
'config' => [],
'aliases' => [],
'providers' => [],
],

],
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)
{
}
}
36 changes: 0 additions & 36 deletions src/Exceptions/Handler.php

This file was deleted.

50 changes: 47 additions & 3 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,59 @@

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'));

$routeFile = fn (string $path) => file_exists($path) ? $path : null;

return (new ApplicationBuilder($app))
->withKernels()
->withEvents()
->withProviders()
->withCommands([
\Butler\Service\Console\Commands\Assets::class,
$app->path('Console/Commands'),
])
->withRouting(
web: $routeFile($app->basePath('routes/web.php')),
api: $routeFile($app->basePath('routes/api.php')),
commands: $routeFile($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()
Expand All @@ -21,6 +66,5 @@ public function registerConfiguredProviders()
parent::registerConfiguredProviders();

$butlerService->registerApplicationProviders();
$butlerService->registerExtraProviders();
}
}
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.

Loading

0 comments on commit 51fb737

Please sign in to comment.