How to Update the Laravel Installer Command
When you globally install the laravel/installer via Composer, you are essentially creating a CLI tool that knows how to bootstrap new projects based on your local configuration. The command composer global require "laravel/installer" sets up an executable named laravel. When you run laravel new project, this tool checks your environment for specific version constraints to determine which codebase to scaffold.
The issue arises when a new Laravel minor or major version is released, such as the jump from 5.6 to 5.7. The global installer often defaults to the latest stable patch of the currently installed framework unless explicitly told otherwise. If your Composer global config still points to an older constraint, or if the installer logic hasn't picked up the new release candidate automatically, you will find that laravel new project generates a 5.6.33 skeleton even though you want 5.7.
To align your CLI tool with the latest framework version without abandoning the laravel new command, you must update the underlying Composer dependencies and potentially adjust how the installer resolves versions. The primary mechanism for this is ensuring that the laravel/laravel package referenced in the installer's logic points to the correct version.
You can achieve this by updating the global installation of the Laravel Installer itself. Run the following command to ensure your global install includes the latest definitions and scripts:
composer update --global
This action refreshes the vendor/ directory within your Composer global cache, ensuring that the script definition for laravel reflects the most recent metadata available from Packagist. However, simply running a global update might not always force the version constraint to shift if the installer is hardcoded to look for specific versions in its internal logic or if you have local overrides.
If the global update does not immediately resolve the version mismatch where laravel new still outputs 5.6.33, you need to inspect your Composer configuration. The installer often looks at the require section of the project being created. To force the creation of a 5.7 project using the command-line tool, you can explicitly pass version constraints directly to the laravel new command:
laravel new project --version=5.7
This approach bypasses any default resolution logic that might be falling back to older patches. It is important to note that this flag availability depends on the specific version of the laravel/installer package you have globally installed. Older versions of the installer may not support passing version flags directly.
If you prefer a more permanent solution that aligns with the workflow you described, consider updating your global composer.json to require a specific version of the Laravel Installer that supports the latest framework releases. Alternatively, you can rely on the create-project command which you mentioned already works for 5.7:
composer create-project --prefer-dist laravel/laravel:5.7 blog
This method is often more robust because it installs the specific version of the Laravel framework and the corresponding installer logic required to manage that version, rather than relying on a globally installed tool that might have stale constraints. The trade-off here is losing the shorthand laravel new syntax in favor of the explicit Composer command, but this ensures your local environment matches the global release exactly.
In some cases, developers find it helpful to remove the global laravel executable entirely and rely solely on composer create-project. This eliminates ambiguity about which version constraint is being applied. If you decide to stick with the CLI tool, ensure that your global Composer cache is cleared to prevent stale metadata from influencing version resolution:
composer clear-cache --global
By combining a global update with explicit version flags or switching to create-project, you can maintain control over which Laravel version is being scaffolded, ensuring your development environment stays synchronized with the latest 5.7 release.