laravel/framework · critical · RuntimeException

A container implementation is required to use the scheduler.

Error message

A container implementation is required to use the scheduler. Please install the illuminate/container package.

What it means

Thrown by Schedule::__construct() (src/Illuminate/Console/Scheduling/Schedule.php:130) when Illuminate\Container\Container is not autoloadable. The scheduler resolves the container, mutexes, and dispatcher from Container::getInstance(), so the container package is mandatory.

Source

Thrown at src/Illuminate/Console/Scheduling/Schedule.php:130

     * Indicates if the schedule should check for the interrupt signal in the cache.
     *
     * @var bool
     */
    public static $interruptible = true;

    /**
     * Create a new schedule instance.
     *
     * @param  \DateTimeZone|string|null  $timezone
     *
     * @throws \RuntimeException
     */
    public function __construct($timezone = null)
    {
        $this->timezone = $timezone;

        if (! class_exists(Container::class)) {
            throw new RuntimeException(
                'A container implementation is required to use the scheduler. Please install the illuminate/container package.'
            );
        }

        $container = Container::getInstance();

        $this->eventMutex = $container->bound(EventMutex::class)
            ? $container->make(EventMutex::class)
            : $container->make(CacheEventMutex::class);

        $this->schedulingMutex = $container->bound(SchedulingMutex::class)
            ? $container->make(SchedulingMutex::class)
            : $container->make(CacheSchedulingMutex::class);
    }

    /**
     * Add a new callback event to the schedule.
     *

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. composer require illuminate/container (and illuminate/cache, illuminate/events for mutexes).
  2. Prefer requiring laravel/framework or illuminate/contracts as a metapackage to pull all deps.
  3. Run composer dump-autoload after dependency changes.
  4. Verify Container::getInstance() returns an instance in your bootstrap.

Example fix

// before
// composer.json -> "illuminate/console": "^11.0"  (no container)

// after
// composer.json -> "illuminate/console": "^11.0",
//                    "illuminate/container": "^11.0"
// or simply
// "laravel/framework": "^11.0"
Defensive patterns

Strategy: validation

Validate before calling

if (! class_exists(\Illuminate\Container\Container::class)) {
    // require illuminate/container before bootstrapping the scheduler
}

Type guard

function schedulerDepsPresent(): bool
{
    return class_exists(\Illuminate\Container\Container::class);
}

Try / catch

try {
    $schedule = new \Illuminate\Console\Scheduling\Schedule();
} catch (\RuntimeException $e) {
    // install missing package, then retry
}

Prevention

When it happens

Trigger: Instantiating new Schedule() in an environment that loads only illuminate/console without illuminate/container (e.g. a minimal composer setup pulling sub-packages directly).

Common situations: Pulling individual illuminate/* packages (console, scheduling) rather than laravel/framework, missing illuminate/container in composer.json, or a broken autoloader after package removal.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/48225e7c346669ef.json. Report an issue: GitHub.