1

I just wanted to install my Symfony 3.2 app on a server with PHP 5.6, and a composer install tells me twig/twig v2.0.0 requires php ^7.0 -> your PHP version (5.6.22) does not satisfy that requirement.

How can I change the twig version that is used in my app? As far as i understand, Symfony uses the twig-bundle (https://packagist.org/packages/symfony/twig-bundle).

Do I need to add the symfony/twig-bundle in a lower version (which one?) or do I need to add the twig/twig v1.31.0 to my composer.json require section?


UPDATE:

My composer.json:

{
    "name": "...",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.2.*",
        "twig/twig": "1.31.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^3.0",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "javiereguiluz/easyadmin-bundle": "^1.16",
        "doctrine/doctrine-fixtures-bundle": "^2.3",
        "symfony/dom-crawler": "^3.2"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": null
    }
}

My command:

Image

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97

1 Answers1

7

You can use Twig 1.x:. Add/change this in your composer.json:

"require": {
    "symfony/symfony": "v3.2.*",
    "twig/twig": "1.31.*"
}

And then run composer update. If you want to know what the difference between install and update is, read this answer.

Community
  • 1
  • 1
Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
  • Thanks for your answer Stephan. I added the twig bundle, but with composer install it still tries to install the v2.0.0. Maybe do I need to update the composer.lock somehow? I'll post my composer.json and the result of the command as an update to my question. – meandeveloper111 Feb 23 '17 at 14:24
  • 2
    after a change in `composer.json` you need to run `composer update` (and not `install`) – Tomasz Madeyski Feb 23 '17 at 14:36
  • Ah yes, of course! Thank you, your answer solved my problem :) – meandeveloper111 Feb 23 '17 at 15:27