Add --target
option to specify Laravel version to install
#383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've added a
--target
option to allow developers to specify which version of Laravel they want to install. This feature has been frequently requested over the years (see #229 in 2022, #250 in 2023, #229 again in 2023, and #319 (comment) in 2024).Recently, I personally encountered the need for this feature when working with a client's server that runs multiple PHP applications that are dependent on PHP 8.1. The version of PHP cannot be changed, and the client is not willing to pay for another server, making it necessary to install Laravel 10 rather than the latest version.
What's the alternative? The documentation doesn't mention any (anymore). As of Laravel 11, documentation on installing with
composer create-project
was removed. Docs is pointing to the laravel installer, which everyone I believe, myself included, enjoys using.This PR would allow:
Also consider "Docker Installation using Sail"
The
laravel.build
(sail-server) is also affected by the absence of this feature, since it relies on the Laravel installer behind the scenes. To understand how the script creates a new project with an older Laravel version, you'd need to inspect not just thelaravel.build
script, but also the Laravel installer's code. This adds unnecessary complexity."Docker Installation using Sail" is recommended like so:
Older Laravel docs (e.g. see Docker Installation Using Sail) don't mention that this command installs the latest Laravel version. This leads to confusion (or is even left unnoticed) when developers expect to install the version they are currently reading about in the documentation.
I've already prepared a solution for myself (see changes in miclaus/sail-server#2 and miclaus/sail-server#3) for the sail-server that adds a
version
query parameter for passing the--target
option to the Laravel installer. This change could easily be added for older docs. Together with this PR's feature, the following would be possible for e.g. Laravel 10:This PR adds flexibility without altering the default experience, and would be particularly developer-friendly for those working with legacy systems or in resource-constrained environments.
I totally agree that installing the current Laravel version should be recommended. Still, IRL sometimes we need to work with what we have, and this change would simplify the process a lot.
Please consider this. I'm sure we can figure something out.