Using Composer to create project and php version

Discussion in 'Programming/Scripts' started by virk6, Mar 8, 2019.

  1. virk6

    virk6 Member HowtoForge Supporter

    I have installed composer globally in /usr/local/bin on my debian 9 system.

    When i use composer to create project like composer create-project magic/xxxx_template ... I got this messages :
    "Installing dependencies (including require-dev) from lock file
    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    - Installation request for doctrine/annotations v1.6.0 -> satisfiable by doctrine/annotations[v1.6.0].
    - doctrine/annotations v1.6.0 requires php ^7.1 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 2
    - Installation request for symfony/debug v4.2.3 -> satisfiable by symfony/debug[v4.2.3].
    - symfony/debug v4.2.3 requires php ^7.1.3 -> your PHP version (7.0.33) does not satisfy that requirement.
    Problem 3
    - symfony/debug v4.2.3 requires php ^7.1.3 -> your PHP version (7.0.33) does not satisfy that requirement.
    - symfony/console v3.4.22 requires symfony/debug ~2.8|~3.0|~4.0 -> satisfiable by symfony/debug[v4.2.3].
    - Installation request for symfony/console v3.4.22 -> satisfiable by symfony/console[v3.4.22].
    "
    I understand the messages that the project require php version more than the default 7.0 which composer use by default.
    I have installed on my machine php versions php 7.1 and php 7.2.2 but how to tell or force composer to use by default php version 7.2.2 ?
    I am told that i have to modify the composer.json file but which one ? i have many composer.json file on my debian 9 system.
    Should i reinstall composer ? Help please.
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    My first suggestion is to remove the composer you installed. Then do
    Code:
    apt-get install composer
    If your use case is such that the above easy solution is not acceptable, you can change default php version to 7.2 with
    Code:
    update-alternatives --config php
    update-alternatives --config php-cgi
    Do understand this breaks all PHP programs that do not work with that other PHP version.
     
  3. virk6

    virk6 Member HowtoForge Supporter

    Thanks You Taleman !
    I am going to try your solution and let you know the results;
    Best regards.
    virk
     
  4. virk6

    virk6 Member HowtoForge Supporter

    I did what you suggested in the forum last week.

    update-alternatives --config php ---> (the first command show this)
    There is only one "alternative" in the php link group (which provides /usr/bin/php)
    Nothing to configure.

    update-alternatives --config php-cgi ((the second command show this)
    There is only one "alternative" in the php-cgi link group (which provides /usr/bin/php-cgi): /usr/bin/php-cgi7.0
    Nothing to configure.

    I want my composer tu use php version 7.2 not 7.0.
    Thanks..
     
  5. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    How were those extra PHP versions installed? If installed with apt-get they are shown in update alternatives. If stuff is available with apt-get, use that. Installing from outside Debian repositories causes more pain than usefulness.
    If you need extra PHP versions, use this method
    https://www.howtoforge.com/tutorial/how-to-install-php-7-for-ispconfig-3-from-debian-packages-on-debian-8-and-9/
    Read also comments, especially comment by @Jesse Norell
     
  6. virk6

    virk6 Member HowtoForge Supporter

    Thanks you Mr Taleman.
    I got composer working now but having new database connection problems
    (SQLSTATE[HY000] [2002] No such file or directory) ..
    i think caused by a different instance of PHP being used by the PHP (php 7.3 / php 7.2 php 7.0 ..)
    As you let me know i will see the php extra version and read the comment by @jesse Norel
     

Share This Page