-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to override Acorn kernel / boot #507
Comments
Maybe I'll check for the existence of \Http\Kernel and \Console\Kernel and load those instead. 🤔 I'll give it a think and come up with a solution. 👍 |
I needed to add a middleware to the kernel so as a workaround for this issue I was able to override the http kernel singleton in functions.php, right after the bootloader has been booted: \Roots\bootloader()->boot();
app()->singleton(
\Illuminate\Contracts\Http\Kernel::class,
CustomKernel::class
); Where the CustomKernel extends the Acorn kernel: namespace App\Core;
use App\Core\Acorn\ViewMiddleware;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Routing\Router;
use Roots\Acorn\Http\Kernel as AcornHttpKernel;
class CustomKernel extends AcornHttpKernel
{
public function __construct(Application $app, Router $router)
{
$this->middlewareGroups["web"][] = ViewMiddleware::class;
parent::__construct($app, $router);
}
} Haven't tested this in production yet, but it seems to work. |
You can pass a callback to Roots\bootloader()->boot(function ($app) {
$app->singleton(
\Illuminate\Contracts\Http\Kernel::class,
\App\Http\MySuperCoolKernel::class
);
}); That should be fine for most of you. If you want to have complete control over the boot process, just bootstrap your kernel, our bootloader will short-circuit. ➡️ Moving this to docs. |
Terms
Summary
I'd like the possibility to provide my own subclasses for the kernels.
Motivation
Why are we doing this?
To allow configuring stuff like bootstrappers and middleware.
What use cases does it support?
For example, I'd like to add the standard TrimStrings middleware.
What is the expected outcome?
Maybe a filter per kernel type?
Potential conflicts / foreseeable issues
Not sure, I guess it depends on how stable you consider the kernel APIs to be.
Additional Context
No response
The text was updated successfully, but these errors were encountered: