skip to Main Content

so i tried to install composer and laravel into Phpstorm, but right now there seems to be a problem installing the composer.json file in php. PHP version is 7.4.8. The error code is as shown below.

   "./composer.json" does not match the expected JSON schema:
    - name : Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$

I tried to look it up for help but it didnt get me far enough, so I was wondering if anyone could help me out with this problem.

this is how my composer.json looked like.

{
  "name": "vendor_name/PhpProjec",
  "description": "description",
  "minimum-stability": "stable",
  "license": "proprietary",
  "authors": [
    {
      "name": "***",
      "email": "[email protected]"
    }
  ],
  "require": {
    "barryvdh/laravel-ide-helper": "v2.7.0"
  }

5

Answers


  1. Are you probably using Composer v2? When I use the given JSON in my local environment using Composer v1, it tells me:

    Deprecation warning: Your package name vendor_name/PhpProjec is invalid, it should not contain uppercase characters. We suggest using vendor_name/php-projec instead. Make sure you fix this as Composer 2.0 will error.

    The error message you’ve provided does not occur on my system. If you are still facing problems after using another package name, please share more details

    Login or Signup to reply.
  2. composer is case sensitive from v1.9 onwards…
    so change "PhpProject" to "phpproject"

       {
      "name": "vendor_name/phpproject",
      "description": "description",
      "minimum-stability": "stable",
      "license": "proprietary",
      "authors": [
        {
          "name": "***",
          "email": "[email protected]"
        }
      ],
      "require": {
        "barryvdh/laravel-ide-helper": "v2.7.0"
      }
    
    Login or Signup to reply.
  3. The problem is in the "name" property

    - name : Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$
    

    Change the "name" property accordingly "vendor-name/project-name"

    eg: "name": "nismi/my-php-project"

    Login or Signup to reply.
  4. Easy fix go to composer.json file find where is capitalizised e.g Izupay/PayMent to izupay/payment this will fix the error.

    {
      "name": "IzuPay/PayMent",
      "description": "description",
      "minimum-stability": "stable",
      "license": "proprietary",
      "authors": [
        {
          "name": "***",
          "email": "[email protected]"
        }
      ],
      "require": {
        "barryvdh/laravel-ide-helper": "v2.7.0"
      }
    

    Working answer is:

    {
      "name": "izupay/payment",
      "description": "description",
      "minimum-stability": "stable",
      "license": "proprietary",
      "authors": [
        {
          "name": "***",
          "email": "[email protected]"
        }
      ],
      "require": {
        "barryvdh/laravel-ide-helper": "v2.7.0"
      }
    
    Login or Signup to reply.
  5. This most likely has to do with the version of Composer you’re using.

    Before Composer version 2.0, a name could contain any character, including white spaces.

    However, from version 2.0 upwards:

    • the name can consists of words separated by -, . or _.
    • the complete name should match ^a-z0-9/a-z0-9$.
    • the name must be lowercased (so instead of vendor_name/PhpProjec, it would be vendor_name/phpprojec
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search