Error installing composer in symfony project 2.8

0

How to install composer in a symfony 2.8 project with php 5.6? here's my composer.json .

{
"name": "SIIG/eTAB",
"description": "SIIG/eTAB",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.3.3",

    "symfony/symfony": "2.6.*",
    "doctrine/orm": "v2.4.4",
    "doctrine/doctrine-bundle": "v1.2.0",
    "twig/extensions": "v1.0.1",
    "symfony/assetic-bundle": "2.3.*@stable",
    "kriswallsmith/assetic": "1.1.x@stable",
    "symfony/swiftmailer-bundle": "v2.3.7",
    "symfony/monolog-bundle": "v2.6.1",
    "sensio/distribution-bundle": "v2.3.4",
    "sensio/framework-extra-bundle": "v2.3.4",
    "sensio/generator-bundle": "v2.3.5",
    "incenteev/composer-parameter-handler": "v2.1.0",

    "doctrine/data-fixtures": "v1.0.0",
    "doctrine/doctrine-fixtures-bundle": "v2.2.0",

    "knplabs/knp-menu-bundle":"dev-master",

    "sonata-project/cache": "dev-master",
    "sonata-project/cache-bundle": "dev-master",
    "sonata-project/datagrid-bundle": "dev-master",
    "sonata-project/core-bundle": "dev-master",
    "sonata-project/admin-bundle": "dev-master",
    "sonata-project/doctrine-orm-admin-bundle": "dev-master",
    "sonata-project/block-bundle": "dev-master",
    "sonata-project/easy-extends-bundle": "dev-master",
    "sonata-project/user-bundle": "dev-master",


    "simplethings/entity-audit-bundle": "v0.6",
    "friendsofsymfony/user-bundle": "v1.3.3",
    "friendsofsymfony/jsrouting-bundle": "v1.5.3"

and it throws me the following error.

    
asked by noe 05.12.2017 в 17:43
source

2 answers

0

Composer can be installed as follows:

  curl -s https://getcomposer.org/installer | php

Then at the root of your project:

composer install
    
answered by 13.12.2018 / 16:19
source
1

The error itself is quite clarifying, you are trying to install version 2.3.2 of twig that requires php7 or higher but your version of php is 5.6.30. At this point you have two options:

  • Update the php version to a newer one. Php7, PHP7.1 and PHP7.2 suppose a great jump in performance with respect to php5.6
  • Install a version of twig that supports php5.6, the latest version is v1.35.0 , adding: "twig/twig" : "^1.35"

Deleting the composer.lock file is a very bad idea. Both the composer.json and composer.lock are files that should be stored in your repository. When composer install, you save the exact commit of the dependencies of your project. If one of these libraries introduces a "backward compatibility break" you can find yourself in the situation of needing to revert the dependencies to a previous state, if you do not have the file composer.lock it can be quite difficult to fix it, especially if you do not have much experience with composer.

On the other hand you should not keep dependencies in dev-master unless it is complete and strictly indispensable (temporary). Sonata libraries have tagged versions, you can find them at packagist . A good starting point are those labeled with 3, for example:

"sonata-project/user-bundle" : "^3"

This week, symfony3.4 and symfony4 so it's possible that they introduce changes in that branch to fix incompatibilities with the latest version.

    
answered by 06.12.2017 в 19:40