How do I initialize a Symfony Console project using Composer so that it restricts the version of Long Term Release?

My goal is to run the Composer require command to initialize the Symfony Console project.

When running the require command, I believe that you can limit the required package to a specific version.

I am considering using this to stick with the longer release version of Symfony, which will be supported for longer.

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

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

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 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 

I created a new directory, changed it, ensured that the composer was updated to the latest version, and ensured that PHP was 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. 

I am very familiar with Symfony and therefore may not understand the relationship between the version number used for the Symfony kernel and the version number used by Symfony / console.

Which composer team launches the require version of the LTS Symfony Console in a new project?

+2
source share
2 answers

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

Firstly, I made sure that I have the latest composer and PHP 7.

Then I restarted the command and found a problem:

I installed this application in a subfolder of the Homestead Improved project, and the composer interactively asked me to use its composer.json file!

I was sloppy and did not read the interactive question completely. I assumed that he asked me to create a new composer.json file. But instead, he asked if I want to hack 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 

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

Choosing the correct answer n , I had no problem and it worked fine.

+1
source

Installation request for symfony / process (blocked in version 2.6.4).

This message means that your symfony/process locked on v2.6.4 (in your composer.lock ). This is confusing as Composer reported No composer.json in the current directory.

Since you chose Y to load composer.json from another folder (possibly from another unrelated project), so next time try not to select it (by choosing n ). Therefore, you can install it in an empty folder. If you want to install it globally, run: composer global require symfony/console .


When you work with existing composer.json and composer.lock , try updating your dependencies:

 composer update --with-dependencies 

Otherwise, uninstall composer.lock and install composer install from scratch.

0
source

Source: https://habr.com/ru/post/1247087/


All Articles