Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

I got symfony/translation errors installing laravel 5 on remote server

Hello, Uploading my laravel 5 app on ubuntu under Digital Ocean server I got error in the browser:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Googling for decision I found that the error could need symfony/translation installation and I tried to install it locally on my kubuntu 18 and got error "

$ composer require symfony/translation                                     
Using version ^5.1 for symfony/translation
./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/translation v5.1.2
    - Conclusion: don't install symfony/translation v5.1.1
    - Conclusion: don't install symfony/translation v5.1.0
    - Conclusion: don't install symfony/translation v5.1.0-RC2
    - Conclusion: don't install symfony/translation v5.1.0-RC1
    - Conclusion: don't install symfony/translation v5.1.0-BETA1
    - Conclusion: don't install symfony/translation 5.2.x-dev
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - Installation request for symfony/translation ^5.1 -> satisfiable by symfony/translation[5.1.x-dev, 5.2.x-dev, v5.1.0, v5.1.0-BETA1, v5.1.0-RC1, v5.1.0-RC2, v5.1.1, v5.1.2].
    - Installation request for symfony/http-kernel (locked at v4.4.9) -> satisfiable by symfony/http-kernel[v4.4.9].

My local composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "spipu/html2pdf": "^5.2",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

How this can be salved ? Thanks!

0 likes
3 replies
Thibaultvanc's avatar

i am pretty sure you do not use the right php version

try php --v and compare the required php version in your composer.json file

mstdmstd's avatar

I check on server and see :

# php -v
PHP 7.2.15-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:37:29) ( NTS )

as in composer.json I have :

 "require": {
        "php": "^7.1.3",
siangboon's avatar

you can't simply change the php version in composer.json (old version) and expected it will work, especially it's more than 2-3 minor versions...

in laravel 5 (depend on version) some use php 5.6 and earlier version, there are quite number of commands deprecated and changes between php 5.6 and 7.1, hence the laravel version had some changes updated according to the php version respectively...

upgrade and test the laravel 5 project to the version as production version in your local first, or, use the same php and laravel version in production...

Please or to participate in this conversation.