I'm trying to create a re-usable custom bundle following the great course on SymfonyCasts. But when I try to install it with composer, the symfony recipes doesn't apply. For example, my bundle isn't registered at all in config/bundles.php
. I read everywhere that the simple fact of setting "type": "symfony-bundle"
in the composer.json should automatically run the recipes, but in my case it simply doesn't.
The strange fact is the recipes does apply on uninstall. Example :
composer remove chinaskijr/mybundle
prints
Symfony operations: 1 recipe (769c88112592ff8a35644e9520929f21)
- Unconfiguring chinaskijr/mybundle (>=v2.x-dev): From auto-generated recipe
But nothing on composer require chinaskijr/mybundle:*@dev
The SymfonyCasts course make us install it through "path" repositories, but I also tried with private gitea repositories and the results was identical.
I also don't think that the issue comes from my bundle cause when I registered it by hands, his code is correctly working.
Here is my composer.json
{
"name": "chinaskijr/mybundle",
"type": "symfony-bundle",
"description": "A bundle for practice",
"version": "v2.x-dev",
"authors": [
{"name": "chinaskijr", "role": "Owner"},
],
"require": {
"php": "^7.2"
},
"autoload": {
"psr-4": {"chinaskijr\\mybundle\\": ""}
}
}
Thank you very much for answering.
EDIT : I'm not sure the problem is from here because I tried to install it on differents projects, and it never works. Here is on symfony/skeleton for example.
{
"type": "project",
"license": "proprietary",
"repositories": [
{"type": "path", "url": "../mybundle"}
],
"require": {
"php": "^7.2",
"ext-ctype": "*",
"ext-iconv": "*",
"chinaskijr/mybundle": "*@dev",
"symfony/console": "5.0.*",
"symfony/dotenv": "5.0.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.0.*",
"symfony/yaml": "5.0.*"
},
"require-dev": {
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.0.*"
}
}
}
EDIT2 : There is the structure. Once activated by hand, services are autowired, I can access them from the container and get the config
All namespaces are prefixed by chinaskijr\mybundle\
following the PSR-0
.
├── composer.json
├── Controller
│ └── MyBundleController.php
├── DependencyInjection
│ ├── Configuration.php
│ └── MyBundleExtension.php
├── MyBundleBundle.php
├── README.md
└── Resources
├── config
│ └── services.xml
└── templates
└── index.html.twig