Dear,
I am approaching to support Flex Installation in my Symfony bundle, and I had a problem.
Let's say MyBundle are depending on another bundle, called TheirBundle. In the old way, the end users will add two bundles into AppKernel at the same time.
class AppKernel extends Kernel
{
public function registerBundles()
{
return [
// ...
new \Their\Symfony\TheirBundle(),
new \My\Symfony\MyBundle(),
];
}
// ...
}
And now, I cannot do that with composer require my/my-bundle because the config/bundles.php was updated with MyBundle only, but TheirBundle. So I don't know how to fix it.
Thanks for your support.
PS: I didn't contribute the recipe of my bundle to Symfony yet. Should I do that to get?
This is not a problem. If your my/my-bundle requires their/their-bundle, Flex will auto-install it if i doesn't have a recipe. If it has a recipe, it will resolve it and apply it to your project.
It's all about correct packagist configuration for their/their-bundle.
Hi @Pierstoval,
Thanks for your quick response.
In my case, the their/their-bundle didn't have a recipe yet. And it was installed by composer already for sure. But its bundle was NOT registered in config/bundles.php, but my bundle. It affects to some services which my bundle requires.
Any suggestion or I missed anything? Thanks in advance.
If their/their-bundle doesn't have a recipe and if it's correctly configured in packagist, Flex is capable of adding it automatically to bundles.php. So if it's not, it's the bundle that's not configured properly. Can you share its packagist link or its github repo?
Make sure that their/their-bundle has the type symfony-bundle in the composer.json. Then Flex will know it is a bundle and auto-generate a recipe registering the bundle if it has none.
Here, https://packagist.org/packages/aws/aws-sdk-php-symfony
Seems it missed the type in composer file.
"type": "symfony-bundle"
A part from this point, are there anything else I need to investigate? Should we write down this point in somewhere of documentation?
Only add "type": "symfony-bundle" and it should work. And obviously you'll need to release a new version.
Hi again. Unfortunately, it didn't work although I added the symfony bundle type to the composer configuration (a forked version)
Here, TheirBundle
https://github.com/trandangtri/aws-sdk-php-symfony/blob/flex/composer.json
Here, MyBundle
https://github.com/trandangtri/sqs-queue-bundle/blob/2.x/composer.json
Seems it's not a root cause.
The error log:
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing aws/aws-sdk-php (3.36.32): Downloading (100%)
- Installing aws/aws-sdk-php-symfony (dev-flex d9ddf66): Downloading (100%)
- Installing tritran/sqs-queue-bundle (2.x-dev b6a1bf2): Downloading (100%)
Writing lock file
Generating autoload files
Symfony operations: 1 recipe (d9a49cc45e034f16a255a5a64eec849b)
- Configuring tritran/sqs-queue-bundle (2.x-dev): From auto-generated recipe
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!!
!!
!! [InvalidArgumentException]
!! AWS SQSClient is required to use queue.
!!
!!
!!
!!
Installation failed, reverting ./composer.json to its original content.
FYI, AWS SQSClient is required to use queue. is my own error message log to check SQSClient loading.
Seems strange... I don't see what's the issue here :confused: :thinking: Maybe others may find something.
Maybe it's a license or package version issue (as package is not released but cloned) ? /cc @fabpot
Hmm. So one of the packages has the correct type, but flex does not generate a re I鈥檝e for it. I noticed that bundle has a non-standard directory structure. I鈥檓 not sure how Flex determines the bundle鈥檚 class. Perhaps the dir structure prevents it from being discovered.
To prove/disprove that theory, you could temporarily move the bundle class to the root - just to see if Flex then generates a recipe for it.
That's because the AWS bundle does not follow the convention for the bundle name. It's currently Aws\Symfony\AwsBundle, but Flex looks for the following bundle class names:
Aws\Symfony\Symfony
Aws\Symfony\AwsSymfony
Aws\Symfony\AwsSymfony
yeah, as the AWS bundle does not use any of the recognized class name, it needs a recipe to configure the class name it needs
@trandangtri Can you submit a pull request to add this recipe (should be in symfony/recipes-contrib)? I would also suggest to make a PR to the bundle repository to change the bundle class name (probably by keeping an alias for BC).
Dear @fabpot
Thanks for your information, I did all your suggestion. Let's see AWS Support team to make an action to do.
Best Regards.
Most helpful comment
Make sure that
their/their-bundlehas the typesymfony-bundlein the composer.json. Then Flex will know it is a bundle and auto-generate a recipe registering the bundle if it has none.