Laravel 11 (#84)

* Convert string references to `::class`

PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.

* Use Faker methods

Accessing Faker properties was deprecated in Faker 1.14.

* Convert route options to fluent methods

Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods.

* Adopt class based routes

* Remove default `app` files

* Shift core files

* Streamline config files

* Set new `ENV` variables

* Default new `bootstrap/app.php`

* Re-register HTTP middleware

* Consolidate service providers

* Re-register service providers

* Re-register routes

* Re-register scheduled commands

* Bump Composer dependencies

* Use `<env>` tags for configuration

`<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI.

Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/

* Adopt anonymous migrations

* Rename `password_resets` table

* Convert `$casts` property to method

* Adopt Laravel type hints

* Mark base controller as `abstract`

* Remove `CreatesApplication` testing trait

* Shift cleanup

* Fix shift first issues

* Updating Rules for laravel 11, sanctum config and pint

* Fix Carbon issue on dashboard

* Temporary fix for tests while migration is issue fixed on laravel side

* Carbon needs numerical values, not strings

* Minimum php version

* Fix domain installation step not fetching the correct company_id

* Fix Role Policy wasn't properly registered

---------
This commit is contained in:
mchev
2024-06-05 11:33:52 +02:00
committed by GitHub
parent 72311db1bd
commit 3259173066
656 changed files with 4964 additions and 7944 deletions

View File

@@ -1,55 +1,73 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
use App\Providers\AppServiceProvider;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
return Application::configure(basePath: dirname(__DIR__))
->withProviders([
\Lavary\Menu\ServiceProvider::class,
])
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
channels: __DIR__.'/../routes/channels.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->redirectGuestsTo(fn () => route('login'));
$middleware->redirectUsersTo(AppServiceProvider::HOME);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$middleware->validateCsrfTokens(except: [
'login',
]);
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
InvoiceShelf\Http\Kernel::class
);
$middleware->append([
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\TrimStrings::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\ConfigMiddleware::class,
]);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
InvoiceShelf\Console\Kernel::class
);
$middleware->web([
\App\Http\Middleware\EncryptCookies::class,
\App\Http\Middleware\VerifyCsrfToken::class,
]);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
InvoiceShelf\Exceptions\Handler::class
);
$middleware->statefulApi();
$middleware->throttleApi('180,1');
/*
|--------------------------------------------------------------------------
| 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.
|
*/
$middleware->replace(\Illuminate\Http\Middleware\TrustProxies::class, \App\Http\Middleware\TrustProxies::class);
return $app;
$middleware->replaceInGroup('web', \Illuminate\Cookie\Middleware\EncryptCookies::class, \App\Http\Middleware\EncryptCookies::class);
$middleware->alias([
'auth' => \App\Http\Middleware\Authenticate::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'bouncer' => \App\Http\Middleware\ScopeBouncer::class,
'company' => \App\Http\Middleware\CompanyMiddleware::class,
'cron-job' => \App\Http\Middleware\CronJobMiddleware::class,
'customer' => \App\Http\Middleware\CustomerRedirectIfAuthenticated::class,
'customer-guest' => \App\Http\Middleware\CustomerGuest::class,
'customer-portal' => \App\Http\Middleware\CustomerPortalMiddleware::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'install' => \App\Http\Middleware\InstallationMiddleware::class,
'pdf-auth' => \App\Http\Middleware\PdfMiddleware::class,
'redirect-if-installed' => \App\Http\Middleware\RedirectIfInstalled::class,
'redirect-if-unauthenticated' => \App\Http\Middleware\RedirectIfUnauthorized::class,
]);
$middleware->priority([
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();