How to Fix Laravel 9 Install Errors with Composer: Correct Syntax and Common Pitfalls

Running composer create-project laravel9 appnamehere fails because Composer interprets laravel9 as a package name rather than a version constraint, preventing folder creation; the correct command is composer create-project --prefer-dist laravel/laravel="9.*" appnamehere.

When attempting a laravel 9 install via command line, developers frequently encounter silent failures where the target directory is never created. This occurs due to a syntax misunderstanding in how Composer resolves package names versus version constraints. According to the laravel/framework source code, successful installation requires specifying the official laravel/laravel skeleton repository with an explicit version constraint that maps to the 9.x release line.

Why composer create-project laravel9 Fails to Create Folders

When you execute composer create-project laravel9 appnamehere, Composer treats laravel9 as the package identifier to fetch from Packagist, not as a version specification. Because no package named laravel9 exists in the registry, Composer throws a [Composer\Downloader\TransportException] Could not download… error and aborts before writing any files to disk. The target folder is never created because the dependency resolution phase fails upstream.

Correct Laravel 9 Install Command Syntax

To perform a valid laravel 9 install, you must specify the laravel/laravel skeleton package and append a version constraint that isolates the 9.x branch:

composer create-project --prefer-dist laravel/laravel="9.*" appnamehere

Alternatively, you can use caret notation:

composer create-project --prefer-dist laravel/laravel:^9.0 appnamehere

Key components of the command:

  • laravel/laravel – The official starter repository containing the default application structure (routes, controllers, configuration files).
  • ="9.*" or ^9.0 – A version constraint that instructs Composer to resolve the latest 9.x release of the skeleton, which in turn requires illuminate/* packages from the framework repository.
  • appnamehere – The target directory that Composer will create and populate. This path must not exist, or must be completely empty, to avoid write conflicts.

Understanding the Package Structure

The laravel/laravel repository serves as the application skeleton, while laravel/framework provides the core Illuminate components. During installation, Composer reads the skeleton's composer.json (located at https://github.com/laravel/laravel/blob/9.x/composer.json), which declares "laravel/framework": "9.*" in its requirements, ensuring the correct framework version is pulled from the laravel/framework repository.

What Happens Under the Hood

When you run the correct laravel 9 install command, Composer performs the following steps according to the framework source:

  1. Skeleton Resolution – Composer clones the laravel/laravel repository and reads its composer.json to determine dependency requirements.
  2. Framework Resolution – Based on the skeleton's requirements, Composer resolves the illuminate/* packages (such as illuminate/support and illuminate/database) from the laravel/framework repository's composer.json (found at https://github.com/laravel/framework/blob/9.x/composer.json).
  3. File Generation – Composer copies the skeleton files into the target directory, including the artisan entry point and src/Illuminate/Foundation/Application.php, which handles service provider registration during bootstrap.
  4. Post-Install Hook – Finally, Composer executes php artisan key:generate to create the application encryption key, completing the installation.

Common Pitfalls During Laravel 9 Installation

Symptom Cause Remedy
"Could not find a matching package" Using laravel9 instead of laravel/laravel as the package name Use the correct package identifier laravel/laravel
Folder not created but no error shown Target directory already exists and contains files Delete or rename the existing folder, or specify a new path
"Your PHP version is 7.x, but Laravel 9 requires ≥ 8.0" Local PHP runtime below minimum requirement Upgrade to PHP 8.0 or higher before installation
Version resolution ignores constraints Outdated Composer binary Run composer self-update to ensure modern constraint parsing

Practical Code Examples


# Standard Laravel 9 install with strict version pinning

composer create-project --prefer-dist laravel/laravel="9.*" my-laravel-9-app

# Using caret syntax for semantic versioning

composer create-project --prefer-dist laravel/laravel:^9.0 my-laravel-9-app

# Non-interactive mode for CI/CD pipelines

composer create-project --prefer-dist --no-interaction laravel/laravel="9.*" ci-laravel-9

# Verify the installation

cd my-laravel-9-app
php artisan --version

Summary

  • Use the correct package name – Specify laravel/laravel, not laravel9, as the first argument to composer create-project.
  • Apply a version constraint – Append ="9.*" or ^9.0 to ensure Composer resolves the 9.x skeleton and corresponding illuminate/* framework packages.
  • Check PHP compatibility – Laravel 9 requires PHP 8.0 or higher; verify your environment with php -v before installing.
  • Ensure directory availability – The target folder must not exist (or must be empty) to prevent Composer from aborting the file generation phase.
  • Understand the dependency chain – Composer resolves versions by reading the skeleton's composer.json, which references the framework repository's composer.json to pull core components like src/Illuminate/Foundation/Application.php.

Frequently Asked Questions

Why does Composer report that it cannot find the laravel9 package?

Composer interprets the first argument after create-project as the package name to fetch from Packagist. Since laravel9 is not a registered package, the command fails during the download phase. You must use laravel/laravel as the package name and specify the version using a constraint like ="9.*".

Can I install Laravel 9 into a folder that already exists?

No. Composer requires the target directory to either not exist or be completely empty. If the folder contains any files, including hidden files like .gitignore, Composer will abort to prevent accidental overwrites. Delete or rename the existing directory before running the installation command.

What PHP version is required for a Laravel 9 install?

Laravel 9 requires PHP 8.0 or higher. If your local environment runs PHP 7.x, Composer will halt with a dependency resolution error stating that your PHP version does not satisfy the "php": "^8.0" requirement found in the framework's composer.json.

How does Composer determine which framework version to install alongside the skeleton?

The laravel/laravel skeleton's composer.json explicitly requires "laravel/framework": "9.*". When Composer processes this requirement, it queries the laravel/framework repository and resolves the specific illuminate/* package versions (such as illuminate/support and illuminate/database) that correspond to the 9.x release line, ensuring version compatibility across the application stack.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →