Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer Json Validation Error for regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$

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"
  }
like image 221
Anon555 Avatar asked Aug 03 '20 03:08

Anon555


2 Answers

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"

like image 135
Nismi Mohamed Avatar answered Sep 29 '22 19:09

Nismi Mohamed


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

like image 40
Nico Haase Avatar answered Sep 29 '22 18:09

Nico Haase