6

I am using in a project a custom repository in github that contains my set of instruments.

The project correctly imports the package inside the /vendor directory,but i cannot use any of the class, because it is not autoloading the contents of the package.

My package composer.json file looks as follows:

{
"name": "mynamespace/toolbox",
"description": "Asdfoobar.",
"keywords": ["mynamespace", "toolbox"],
"license": "MIT",
"require": {
    "php": ">=5.4"          
},
"require-dev": {
    "codeception/codeception": "2.0.2",
    "codeception/specify": "0.3.6",
    "codeception/verify": "0.2.7",
    "mockery/mockery": "0.9.1"
},
"autoload": {
    "psr-4": {
        "Mynamespace\\": "src/Mynamespace",
        "Mocks\\": "tests/Mocks"
    }
},
"scripts": {
    "post-install-cmd": [

    ],
    "post-update-cmd": [
        "php vendor/bin/codecept run"
    ]
},
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "stable"

}

Inside the project instead, the composer.json file looks as follows:

    "require": {
       [...stuff...]
       "Mygitrepo/toolbox": "dev-master" 
    },
    "repositories": [        
    {
        "type": "package",
        "package": {
            "name": "Mygitrepo/toolbox",
            "version": "master",
            "source": {
                "url": "https://github.com/Mygitrepo/toolbox.git",
                "type": "git",
                "reference": "master"
            }
        }
    }
]

The final autoload_psr4.php after doing composer update, composer dump looks like following: No trace of "Mynamespace"

return array(
  'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
  'Ivory\\LuceneSearchBundle\\' => array($vendorDir . '/egeloen/lucene-search-bundle'),
  'Facebook\\' => array($vendorDir . '/facebook/php-sdk-v4/src/Facebook'),
);

Any help ?

1 Answer 1

12

This answer applies here as well.

Because you are providing a "type:package" entry in "repositories", you are disabling the composer.json file in the package.

And there is no autoloading defined in the package definition, so the package is not autoloaded at all.

Solution: Don't use the "type:package" entry for repositories you own and which have a composer.json file inside.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.