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

Binapick's avatar

Laravel 11 Composer could not detect the root package (laravel/laravel)

Hi,

I have install a fresh Laravel 11 via Composer. I get always following messages if i tried to add a package:

Composer could not detect the root package (laravel/laravel) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version

Has anyone a solution for me, to fix this problem?

0 likes
12 replies
LaryAI's avatar
Level 58

It seems like Composer is having trouble identifying the version of your Laravel application. This can sometimes happen if the composer.json file in your project is missing certain information or if there's a misconfiguration. Here's a step-by-step solution to try and resolve this issue:

  1. Ensure that your composer.json file is properly set up. It should contain a name and description field, and most importantly, it should have a require section that includes laravel/framework with the correct version constraint for Laravel 11. Here's an example of what the relevant part of your composer.json might look like:
{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "require": {
        "php": "^8.0",
        "laravel/framework": "^11.0"
    },
    // ... other settings and dependencies
}
  1. Run composer update to make sure all your dependencies are up to date. This will also regenerate the composer.lock file, which might help Composer detect the correct version of your root package.
composer update
  1. If the issue persists, try clearing Composer's cache. Sometimes a corrupted cache can cause issues with package detection.
composer clear-cache
  1. After clearing the cache, try installing the package again.
composer require some/package

Replace some/package with the actual package name you are trying to install.

  1. If none of the above steps work, check the Composer documentation regarding the root package version issue: https://getcomposer.org/root-version. It might be possible that you need to explicitly define the version of your root package in composer.json if Composer is unable to deduce it from your VCS.
{
    "version": "11.0.0",
    // ... other settings
}

Replace 11.0.0 with the actual version of your Laravel application.

  1. Lastly, if you're still facing issues, consider seeking help from the Laravel community or checking if there are any open issues on the Laravel GitHub repository that might be related to your problem.

Remember to always back up your composer.json and composer.lock files before making changes, so you can easily revert if something goes wrong.

1 like
Binapick's avatar

I have everything that the A.I. tried as described, but the result remains the same

1 like
martinbean's avatar
Level 80

@binapick It’s just a warning. There’s nothing to “fix”. Either ignore it, or add a version key to your application’s composer.json file.

3 likes
jekinney's avatar

@martinbean There is an issue with a few of the first party plugins not registering the app contracts currently. Specifically this AM it tried to use Laravel 11 and Jetstream with Inertia and unable to "register" from a contract binding missing that should have went in the app.php config folder.

So there are some random bugs still. I wouldn't disregard all the errors and warnings on a new install. (Haven't replied to you in about 6 or more years now I think! Good day Sir!)

I haven't had time to dig into it but I did find this thread via google on lunch break...lol

Illuminate\ Contracts \Container\ BindingResolutionException

Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.
martinbean's avatar

@jekinney That’s different issues. I’m hearing there are various issues with Laravel 11.x and first party packages like this, but that’s to be expected with a brand new release.

The Composer version issue, that’s something I’m noticing when running composer commands but the command (and application) still runs fine.

1 like
jlrdw's avatar

Yes you need to make sure your package is laravel 11 ready. Usually hold off upgrading two or three weeks to give those package a chance to update.

Note that this same question comes up on every laravel release, with the same answers.

3 likes
icqx's avatar

Make sure you have promession

sudo chmod o+w /example-app/ -R
sudo chown www-data:www-data -R /example-app/

then update your composer

./vendor/bin/sail composer update
#or
composer update

now you can use :

./vendor/bin/sail composer require laravel/breeze --dev
#or
composer require laravel/breeze --dev
dotJan's avatar

Seems to have changed in Composer version 2.7.2 getcomposer.org/changelog/2.7.2 Added warning when the root version cannot be detected (#11858)

carvellho's avatar

@dotJan | Same thing, after updating composer. Composer version 2.7.2 2024-03-11 17:12:18

gabebruno's avatar

In the new version of Composer, I believe that after version 2.7.0, there must be a "version" property at the beginning of the file composer.json, below the "name", like this:

{
    "name": "laravel/laravel",
    "version": "8",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",

Just add this property and the message will disappear.

12 likes
ammarsdc's avatar

@gabebruno thanks for this reply. May I know why during initializing new project, this is not included since composer require this now and onwards. Btw, juat now I created the project via Herd.

Please or to participate in this conversation.