Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[12.x] Explicitly bind Console Kernel in bootstrap/app.php for … #6633

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

Open
wants to merge 1 commit into
base: 12.x
Choose a base branch
from

Conversation

raphael123514
Copy link

…proper Artisan command and schedule handling

Issue

With the new fluent configuration API introduced in Laravel 12 for bootstrap/app.php, the Console Kernel is not automatically registered in the service container. This causes scheduled commands and Artisan commands to fail silently or report messages like:

No scheduled commands are ready to run.

and prevents proper execution of Artisan commands.


Solution

This pull request explicitly binds the Illuminate\Contracts\Console\Kernel interface to the App\Console\Kernel implementation inside bootstrap/app.php. This ensures that the framework can correctly resolve the Console Kernel when handling scheduled tasks and Artisan commands.


Changes made

Added the following binding in bootstrap/app.php:

use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
use App\Console\Kernel as AppConsoleKernel;

$app->singleton(ConsoleKernelContract::class, function ($app) {
    return $app->make(AppConsoleKernel::class);
});

…proper Artisan command and schedule handling

### Issue

With the new fluent configuration API introduced in Laravel 12 for `bootstrap/app.php`, the Console Kernel is not automatically registered in the service container. This causes scheduled commands and Artisan commands to fail silently or report messages like:

> No scheduled commands are ready to run.

and prevents proper execution of Artisan commands.

---

### Solution

This pull request explicitly binds the `Illuminate\Contracts\Console\Kernel` interface to the `App\Console\Kernel` implementation inside `bootstrap/app.php`. This ensures that the framework can correctly resolve the Console Kernel when handling scheduled tasks and Artisan commands.

---

### Changes made

Added the following binding in `bootstrap/app.php`:

```php
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
use App\Console\Kernel as AppConsoleKernel;

$app->singleton(ConsoleKernelContract::class, function ($app) {
    return $app->make(AppConsoleKernel::class);
});
@GrahamCampbell GrahamCampbell changed the title [8.x / 12.x] Explicitly bind Console Kernel in bootstrap/app.php for … [12.x] Explicitly bind Console Kernel in bootstrap/app.php for … Jun 21, 2025
@AhmedAlaa4611
Copy link
Contributor

I think it should be made in the core for two reasons:

  • This file is all about the configuration that the user may need to change.
  • This is against the slim skeleton we have made in Laravel 12!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants