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

musa11971's avatar

All new Laravel instances are broken (with Laravel installer)

Something seems to be wrong with freshly created Laravel instances on my machine.

  1. laravel new demo -> "Application ready! Build something amazing."
  2. Open http://demo.test/
  3. Exception gets thrown: Image
 Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) 

Does anyone know how I can solve this?

Additional information:

  • laravel/installer version: 2.3.0
  • laravel/valet version: 2.5.3
  • composer version: 1.7.2
  • PHP version: 7.2.24
0 likes
21 replies
Tray2's avatar

What happends if you create it with composer instead?

composer create-project laravel/laravel demo

Do you get the same error?

musa11971's avatar

Unfortunately the same result.

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

Then there is nothing wrong with the installer.

I just did a fresh install without any issues.

Have you changed anything in your php.ini or any other config files?

Tray2's avatar

If you create a php file with the following content and run it what is the result?

<?php
    echo Locale::getDefault();

php <file.php>

Tray2's avatar

My guess is that Symfony does not like en_US_POSIX try updating it to en_US

musa11971's avatar

@tray2

In bootstrap/app.php just before $app gets returned, I added:

Locale::setDefault('en_US');

Tinker now shows:

.. but the same exact exception gets thrown when browsing the URL.

Tray2's avatar

Are you using any special UTF8 character set?

musa11971's avatar

macOS Catalina 10.15.1.

Now that I think about it... this only started happening after I updated from Mojave to Catalina.

Tray2's avatar
Tray2
Best Answer
Level 73

I'm running Catalina without any issues like that.

Try running valet install again

1 like
musa11971's avatar

@tray2 Reinstalled Valet and everything seems to be working again! Thanks.

1 like
ikkebra's avatar

I am running Mojave and this happened yesterday when symfony/translation upgraded to v4.4.0. I fixed it by putting "symfony/translation": "4.3.8" in my composer.json and this fixed it.

TobyRussell's avatar

I had the same issue. I'm running Sierra, 10.12.6. Other details:

  • PHP 7.3.8
  • Laravel installer 3.0.1
  • Composer 1.9.0
  • Valet 2.5.3

Neither a reinstall of Valet nor a reinstall of Laravel helped.

Procedure:

composer create-project --prefer-dist laravel/laravel=5.8.35 jot

Error message as above on issuing php artisan, but site reachable at jot.test.

Edited composer.lock: symfony/translation-contracts from v2.0.0 to:

"name": "symfony/translation-contracts", 2721 "version": "v1.1.7",

Edited composer.json, added (to "require" list):

"symfony/translation-contracts": "^1.1.6"

Ran composer update. Problem solved.

2 likes
ncltours's avatar

Check php in composer.json. You should have same php version installed in your server. Then it works.

2 likes
mallahsoft's avatar

i got the same error

i solved it by add

"symfony/translation": "4.3.8"

to my composer.json file

and then run composer update

every thing work good after that

derstrom's avatar

In my case this issue was happening even after running composer install when it was definitely running on PHP 7.2 or higher. Removing Valet, reinstalling Valet, verifying php -v was pointing to the right version and even running valet use [email protected] made no difference.

As soon as I did a phpinfo() in the Laravel project, it was showing that it was still running on PHP 7.1.x.

It turns out that Laravel Valet was still using the php.ini file that points to the original version of PHP that is installed on my machine. Why? Because ~/.config/valet/valet.sock wasn't being removed by Laravel Valet, which I presume happens when you uninstall Laravel Valet or change what PHP version it should use.

I just needed to remove the file and I then ran valet install && valet use [email protected] again to be on the safe side:

rm ~/.config/valet/valet.sock && valet install && valet use [email protected]

If this fixes your problem, you won't need to lock the symfony/translation version in your composer.json :).

1 like
dpk942's avatar

I have the same problem, even with my machine working on PHP 7.3, valet was still using PHP 7.1

Please or to participate in this conversation.