使用 composer create-project 安装特定的 laravel 版本

2022-01-21 00:00:00 php laravel composer-php

安装 Laravel 最快最简单的方法是通过 composer 命令.从 laravel 文档 (http://laravel.com/docs/quick) 可以看出,我们可以这样安装它:

The fastest and simplest way of installing Laravel is via composer command. From the laravel docs (http://laravel.com/docs/quick), it shows that we can install it with this:

composer create-project laravel/laravel your-project-name --prefer-dist

但是,当您运行上述命令时,它将获取最新版本的 Laravel.如果我想安装最新版本的 4.0.x,我该如何控制它?或者,4.2 出来时 4.1.x?

But, when you run the above command, it will grab the latest version of Laravel. How can I control it if I want to install latest version of 4.0.x? Or, 4.1.x when 4.2 is out?

推荐答案

来自 composer help create-project 命令

create-project 命令从给定的项目创建一个新项目
打包到一个新目录中.如果在没有参数的情况下执行并且在带有 composer.json 文件的目录,它安装当前项目的软件包.
您可以使用此命令来引导新项目或设置干净
为您的项目开发人员提供版本控制的安装.

The create-project command creates a new project from a given
package into a new directory. If executed without params and in a directory with a composer.json file it installs the packages for the current project.
You can use this command to bootstrap new projects or setup a clean
version-controlled installation for developers of your project.

[版本]
您还可以使用 = 或 : 指定具有包名称的版本分隔符.
要安装不稳定的软件包,请指定您想要的版本,或者使用 --stability=dev (其中 dev 可以是 RC 之一,测试版、阿尔法版或开发版).

[version]
You can also specify the version with the package name using = or : as separator.
To install unstable packages, either specify the version you want, or use the --stability=dev (where dev can be one of RC, beta, alpha or dev).

此命令有效:

composer create-project laravel/laravel=4.1.27 your-project-name --prefer-dist

这适用于 * 符号.

相关文章