the-benchmarker/web-frameworks · critical · RuntimeException

Unable to load application. - Type `composer install` if…

Error message

Unable to load application.
- Type `composer install` if you are developing locally.
- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.
- Type `docker-compose run laminas composer install` if you are using Docker.

What it means

laminas-mvc's public/index.php checks whether the Application class exists after including vendor/autoload.php. If Composer dependencies were never installed, the autoloader cannot provide laminas-mvc's Application, so the bootstrap throws a RuntimeException explaining that `composer install` must be run.

Solutions

  1. Run `composer install` in the project root to create vendor/ and the autoloader
  2. If using Vagrant: `vagrant ssh -c 'composer install'`; if using Docker: `docker-compose run laminas composer install`
  3. Verify PHP/Composer platform requirements are met (composer check-platform-reqs) so install does not fail silently
  4. Ensure the deploy pipeline runs composer install (with --no-dev in production) before serving public/index.php

Example fix

// before
git clone <skeleton> && php -S 0.0.0.0:8080 -t public
// -> RuntimeException: Unable to load application.

// after
composer install
php -S 0.0.0.0:8080 -t public
Defensive patterns

Strategy: validation

Validate before calling

// run before serving or in CI before deploy
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
    fwrite(STDERR, "vendor/ missing: run composer install\n");
    exit(1);
}
if (!class_exists(\Laminas\Mvc\Application::class)) {
    fwrite(STDERR, "laminas-mvc not installed: run composer install\n");
    exit(1);
}

Type guard

null

Try / catch

try {
    $app = Application::init($appConfig);
} catch (\Throwable $e) {
    error_log('Bootstrap failed (did you run composer install?): ' . $e->getMessage());
    http_response_code(500);
    exit(1);
}

Prevention

When it happens

Trigger: Opening the laminas skeleton app in a browser (or running public/index.php) when the vendor/ directory is absent or incomplete — i.e. composer install was never executed in the project root, or vendor/autoload.php was wiped.

Common situations: Fresh clone of the repository without running composer install; deploying to a host where the build step skipped Composer; disk cleanup or .gitignore excluded vendor/ and it was not rebuilt; running the app inside a container/vagrant image that was never provisioned.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of the-benchmarker/web-frameworks@3795a31d72 (2026-09-15). Data as JSON: /api/errors/c1abdc4522038224. Report an issue: GitHub.

Appendix: source

Thrown at php/laminas/public/index.php:27

 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));

// Decline static file requests back to the PHP net/http webserver
if (php_sapi_name() === 'cli-server') {
    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
    if (is_string($path) && __FILE__ !== $path && is_file($path)) {
        return false;
    }
    unset($path);
}

// Composer autoloading
include __DIR__ . '/../vendor/autoload.php';

if (! class_exists(Application::class)) {
    throw new RuntimeException(
        "Unable to load application.\n"
        . "- Type `composer install` if you are developing locally.\n"
        . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
        . "- Type `docker-compose run laminas composer install` if you are using Docker.\n"
    );
}

// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
if (file_exists(__DIR__ . '/../config/development.config.php')) {
    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
}

// Run the application!
Application::init($appConfig)->run();

View on GitHub (pinned to 3795a31d72)