{"record":{"id":"c1abdc4522038224","repo":"the-benchmarker/web-frameworks","slug":"unable-to-load-application-type-composer-install-if-you-are","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"php/laminas/public/index.php","lineNumber":27,"sourceCode":" * This makes our life easier when dealing with paths. Everything is relative\n * to the application root now.\n */\nchdir(dirname(__DIR__));\n\n// Decline static file requests back to the PHP net/http webserver\nif (php_sapi_name() === 'cli-server') {\n    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));\n    if (is_string($path) && __FILE__ !== $path && is_file($path)) {\n        return false;\n    }\n    unset($path);\n}\n\n// Composer autoloading\ninclude __DIR__ . '/../vendor/autoload.php';\n\nif (! class_exists(Application::class)) {\n    throw new RuntimeException(\n        \"Unable to load application.\\n\"\n        . \"- Type `composer install` if you are developing locally.\\n\"\n        . \"- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\\n\"\n        . \"- Type `docker-compose run laminas composer install` if you are using Docker.\\n\"\n    );\n}\n\n// Retrieve configuration\n$appConfig = require __DIR__ . '/../config/application.config.php';\nif (file_exists(__DIR__ . '/../config/development.config.php')) {\n    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');\n}\n\n// Run the application!\nApplication::init($appConfig)->run();\n","sourceCodeStart":9,"sourceCodeEnd":43,"githubUrl":"https://github.com/the-benchmarker/web-frameworks/blob/3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2/php/laminas/public/index.php#L9-L43","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `composer install` in the project root to create vendor/ and the autoloader","If using Vagrant: `vagrant ssh -c 'composer install'`; if using Docker: `docker-compose run laminas composer install`","Verify PHP/Composer platform requirements are met (composer check-platform-reqs) so install does not fail silently","Ensure the deploy pipeline runs composer install (with --no-dev in production) before serving public/index.php"],"exampleFix":"// before\ngit clone <skeleton> && php -S 0.0.0.0:8080 -t public\n// -> RuntimeException: Unable to load application.\n\n// after\ncomposer install\nphp -S 0.0.0.0:8080 -t public","handlingStrategy":"validation","validationCode":"// run before serving or in CI before deploy\nif (!file_exists(__DIR__ . '/../vendor/autoload.php')) {\n    fwrite(STDERR, \"vendor/ missing: run composer install\\n\");\n    exit(1);\n}\nif (!class_exists(\\Laminas\\Mvc\\Application::class)) {\n    fwrite(STDERR, \"laminas-mvc not installed: run composer install\\n\");\n    exit(1);\n}","typeGuard":"null","tryCatchPattern":"try {\n    $app = Application::init($appConfig);\n} catch (\\Throwable $e) {\n    error_log('Bootstrap failed (did you run composer install?): ' . $e->getMessage());\n    http_response_code(500);\n    exit(1);\n}","preventionTips":["Always run composer install immediately after cloning the skeleton","Include a composer install step in Dockerfile/vagrant provisioning and CI pipelines","Use composer install --no-dev -o for production builds","Check composer.json/composer.lock are committed so installs are reproducible"],"tags":["php","laminas","composer","bootstrap"],"backgroundTag":"missing-dependency","analyzedSha":"3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2","analyzedAt":"2026-09-15T02:39:22.409Z","contentChangedAt":"2026-09-15T02:39:22.409Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}