Home > Software engineering >  Local composer package in Laravel does not match the expected JSON scheme
Local composer package in Laravel does not match the expected JSON scheme

Time:08-01

I'm trying to load a local package into my Laravel 8 project, but am getting the following error in ./composer.json:

  "./composer.json" does not match the expected JSON schema:                                                     
   - repositories[5].url : The property url is required                                                          
   - repositories[5].type : Does not have a value in the enumeration ["composer"]                                
   - repositories[5].type : Does not have a value in the enumeration ["vcs","github","git","gitlab","bitbucket"  
  ,"git-bitbucket","hg","fossil","perforce","svn"]                                                               
   - repositories[5].type : Does not have a value in the enumeration ["artifact"]                                
   - repositories[5].type : Does not have a value in the enumeration ["pear"]                                    
   - repositories[5].package : The property package is required                                                  
   - repositories[5].type : Does not have a value in the enumeration ["package"]                                 
   - repositories[5] : Failed to match at least one schema                                                       
   - repositories[5] : Must contain no more than 1 properties                                                    
   - repositories[5].type : String value found, but a boolean is required                                        
   - repositories[5].type : Does not have a value in the enumeration [false]                                     
   - repositories[5].path : String value found, but a boolean is required                                        
   - repositories[5].path : Does not have a value in the enumeration [false] 

My composer.json file contains the following for the require and repos section:

"repositories": [
    {
      "type": "vcs",
      "url": "[email protected]:company/pkg-fudge-inbound-management-bridge.git"
    },
    {
      "type": "vcs",
      "url": "[email protected]:company/pkg-inbound-management.git"
    },
    {
      "type": "vcs",
      "url": "[email protected]:company/pkg-blog.git"
    },
    {
      "type": "vcs",
      "url": "[email protected]:company/pkg-credit-score.git"
    },
    {
      "type": "vcs",
      "url": "[email protected]:company/pkg-policies.git"
    },
    {
      "type": "path",
      "path": "/Users/ryanholton/Sites/laravel-packages/pkg-cms"
    }
],
"require": {
    "php": "^7.3",
    "doctrine/dbal": "^2.11",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/framework": "8.60.*",
    "laravel/tinker": "^2.0",
    "company/pkg-fudge-inbound-management-bridge": "1.1.*",
    "company/pkg-inbound-management": "2.0.*",
    "company/pkg-blog": "1.4.*",
    "company/pkg-credit-score": "1.2.*",
    "company/pkg-policies": "1.0.*",
    "company/pkg-cms": "*"
}

Not sure why I'm getting this error, never had it with local packages before, what am I missing?

CodePudding user response:

As error said your last item in repositories array should look like:

{
  "type": $type,
  "url": //here you have to define url
  "path": "/Users/ryanholton/Sites/laravel-packages/pkg-cms"
}

and your $type variable should have 1 of the values below:

"vcs","github","git","gitlab","bitbucket" ,"git-bitbucket","hg","fossil","perforce","svn","composer","artifact","pear","package"

If you are trying yo add package, then $type should be "package".

CodePudding user response:

Try this!

{
"repositories": [
        {
            "type": "package",
            "package": {
                "name": "name/example-package",
                "version": "dev-master",
                "source": {
                    "url": "[email protected]:company/pkg-policies.git",
                    "type": "git",
                    "reference": "dev-master"
                }
            }
        }
    ]
}

CodePudding user response:

Based on the docs: https://getcomposer.org/doc/05-repositories.md#path

You need to define like this

{
    "repositories": [
        {
            "type": "path",
            "url": "/Users/ryanholton/Sites/laravel-packages/pkg-cms"
        }
    ],
}

So it seems you just need to replace path with url.

  • Related