Reputation: 17181
I have a local dependency which is hosted on a private Gitlab repo. I am however, having difficulty pulling this into my project via Composer.
My composer.json
:
"require": {
"crmpicco/GolfBundle": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"name": "crmpicco/GolfBundle",
"version": "dev-master",
"source": {
"url": "https://git.crmpicco.com/rfc1872/golfbundle.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"crmpicco\\GolfBundle\\": ""
}
}
}
}
],
When I look in the vendor directory the directories are doubled-up when I would not expect that, e.g.
/vendor/crmpicco/GolfBundle/crmpicco/GolfBundle
When I run a composer update crmpicco\GolfBundle
I get the following error when Symfony tries to do a cache:clear:
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted
to load class "crmpiccoGolfBundle from namespace "crmpicco\GolfBundle".
Did you forget a "use" statement for "crmpicco\GolfBundle\crmpiccoGolfBundle"?
in /var/www/crmpicco/symfony/app/AppKernel.php:31
What am I missing/doing wrong in my composer.json
setup?
Bundle dir structure:
/crmpicco
/GolfBundle
/Component
/DependencyInjection
crmpiccoGolfBundle.php
Bundle composer.json:
{
"name": "crmpicco/GolfBundle",
"type": "library",
"description": "A Symfony 2 bundle which provides an easy way to handle billing and subscriptions.",
"license": "MIT",
"require": {
"php": ">=7.0",
"symfony/config": "~2.8.34",
"symfony/dependency-injection": "~2.8.34",
"symfony/http-kernel": "~2.8.34",
},
"autoload": {
"psr-4": {
"crmpicco\\GolfBundle\\": ""
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative"
}
}
Upvotes: 1
Views: 467
Reputation: 22174
You should not use package
type for repositories which contains valid composer.json
. This type was designed for packages without composer.json
, so this file will be completely ignored, same as updates in your package.
In your case it is better to define it as git
:
"repositories": [
{
"type": "git",
"url": "https://git.crmpicco.com/rfc1872/golfbundle.git"
}
],
Upvotes: 1
Reputation: 1844
Ok. As I see you have wrong psr-4
autoload config in your bundle's composer.json
You have to change it to the following:
"autoload": {
"psr-4": {
"crmpicco\\GolfBundle\\": "crmpicco/GolfBundle"
}
}
Also If you don't want duplicating of dirs, move your bundle's contents to the root dir and then don't change composer.json
contents. Dirs duplicate because Composer creates dir structure based on name
property which is also crmpicco/GolfBundle
in your case.
Upvotes: 1