本文介绍了如何使用Composer初始化Symfony Console项目以使其坚持长期发行版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是运行Composer的 require 命令来初始化Symfony Console项目。

My goal is to run a Composer's require command to initialise a Symfony Console project.

在运行Composer时 require 命令,我相信可以将所需的软件包限制为特定版本。

When running composer's require command, I believe it is possible to restrict the required package to specific a version.

我正在考虑使用

根据当前的LTS版本是 3.4

According to the Symfony Release Process the current LTS version is 3.4.

根据和,该软件包和版本可以指定表示为: symfony / console:〜3.4

According to Composer's require command documentation and Composer's version constraints documentation, the package and version can be specified as: symfony/console:~3.4.

但是,当我运行 composer 命令在一个空目录中安装symfony / console 3.4我遇到以下错误。 (我的MacOS High Sierra上安装了PHP和Composer):

However, when I run the composer command to install symfony/console 3.4 in an empty directory I get the following errors. (I have PHP and Composer is installed on my MacOS High Sierra):

$ mkdir foo
$ cd foo
$ composer self-update
You are already using composer version 1.6.2 (stable channel).
Johns-MBP:foo jw$ php --version
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

我创建了一个新目录,将其更改为该目录,确保composer已更新为最新版本,并确保PHP为7。*。

I have created a new directory, changed into it, ensured composer is updated to the latest version and ensured PHP is 7.*.

$ composer require symfony/console:~3.4
No composer.json in current directory, do you want to use the one at /Users/me/Documents/Projects/FilterProject/filter-environment? [Y,n]? Y
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install symfony/console v3.4.3
    - Conclusion: don't install symfony/console v3.4.2
    - Conclusion: don't install symfony/console v3.4.1
    - symfony/process v2.6.4 conflicts with symfony/console[v3.4.0].
    - symfony/console v3.4.0 conflicts with symfony/process[v2.6.4].
    - Installation request for symfony/console ~3.4 -> satisfiable by symfony/console[v3.4.0, v3.4.1, v3.4.2, v3.4.3].
    - Installation request for symfony/process (locked at v2.6.4, required as ~2.0) -> satisfiable by symfony/process[v2.6.4].


Installation failed, reverting ./composer.json to its original content.

我对Symfony还是很陌生,因此可能会误解用于Symfony内核的版本号之间的联系

I am quite new to Symfony and so may be misunderstanding the connection between the version number used for Symfony core versus the version number used by Symfony/console.

哪个composer命令运行一次以要求的LTS版本

Which composer command does one run to require the LTS version of Symfony Console in fresh project?

推荐答案

由于@Cerad的评论,我设法使它起作用。

I have managed to get this to work, thanks to @Cerad's comment.

首先,我确保拥有最新版本的composer和PHP 7。

First, I ensured that I have the latest version of composer and PHP 7.

然后我重新运行该命令并发现了问题所在:

Then I re-ran the command and spotted the problem:

我正在将这个应用程序安装在Homestead Improvement项目的子文件夹中,并且作曲家互动地要求我使用其编写器.json 文件!

I was installing this application in a sub-folder of a Homestead Improved project and composer was interactively asking me to use its composer.json file!

我很草率,没有完全阅读交互式问题。我以为是要我创建一个新的 composer.json 文件。但是相反,它询问的是我是否要修改上面父项目的composer.json文件。

I was being sloppy and did not read the interactive question fully. I assumed it was asking me to create a new composer.json file. But instead it was asking if I wanted to ammend the composer.json file of the parent project above.

$ composer require symfony/console:~3.4
No composer.json in current directory, do you want to use
the one at /Users/me/Documents/Projects/FilterProject/filter-environment? [Y,n]? Y

如果我回答了 Y ,那么我的选择与父项目中的某些依赖项冲突。

If I answered Y then my choice conflicts with some dependencies in the parent project.

通过选择 n 的正确答案,我没有问题,并且工作正常。

By choosing the correct answer of n I did not have a problem and it worked OK.

这篇关于如何使用Composer初始化Symfony Console项目以使其坚持长期发行版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 14:41