Skip to content

Define requirement to the twig bundle for UX Component and UX Live Components #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

alexander-schranz
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Tickets Fix #...
License MIT

Define requirement to the twig bundle for UX Component and UX Live Components. Currently installing ux component and live component fails. Both have a direct requirement to the TwigBundle as both require a service named twig.

Without defining this requirement the installation of the package will fail when not already have twig-bundle installed: https://github.com/schranz-php-recipes/symfony-recipes-php/actions/runs/3567748595/jobs/5995813798

Related PR: #313

@alexander-schranz alexander-schranz force-pushed the feature/define-require-twig-bundle branch from 1871de9 to c7095d4 Compare November 28, 2022 19:13
@@ -29,7 +29,9 @@
"php": ">=8.0",
"symfony/property-access": "^5.4|^6.0",
"symfony/serializer": "^5.4|^6.0",
"symfony/ux-twig-component": "^2.5"
"symfony/twig-bundle": "^5.4|^6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TwigBundle is not required here (nothing imported from TwigBundle in src only from twig).

Copy link
Contributor Author

@alexander-schranz alexander-schranz Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the component it requires the specific service twig and so has a requirement to twig bundle itself. Because that is the bundle providing that service definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh do you think about this one?

->setArguments([new Reference('twig')]);

If, we add the bundle this can be removed

$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['TwigBundle'])) {
return;
}

And there are other missing dependencies too, like dependency-injection, router, http-kernel, ... don't we should add those too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what currently failing the installation inside a empty skeleton. I personally would if they are required, but not sure, wait what @weaverryan think about that.

@kbond
Copy link
Member

kbond commented Dec 6, 2022

Thanks for looking into this!

I can't remember exactly how it is related but the failing CI is what I ran into when iterating on #313: the form component not being available. Does manually enabling the form component in the test kernel help?

@alexander-schranz
Copy link
Contributor Author

@kbond I did found out it its an issue in the Symfony core here a little inconsistent is between TwigExtension.php and ExtensionPass.php: symfony/symfony#48373 (comment) I'm not sure if we should add the $container::willBeAvailable to the compilerpass or even remove it from the TwigExtension.

@kbond
Copy link
Member

kbond commented Dec 6, 2022

So the issue is there's no way to enable the twig form extension if symfony/form isn't in composer.json's require?

I think that was the nuance that #313 solved: adding twig-bundle and form to require-dev allowed it to be enabled.

Agree that this is a problem - I remember it took me some time to figure out what was going on.

@alexander-schranz
Copy link
Contributor Author

I think that was the nuance that #313 solved: adding twig-bundle and form to require-dev allowed it to be enabled.

Yes that is the case as then also the form.extension is not installed and so that is not failing in that case, but it does sadly so not define all require dependencies and fails if twig-bundle is not already installed. I stumble it over it in the recipes CI testing as the recipe update of symfony/ux components failed as it did not define this requirement.

I think I will target a pull request in symfony/symfony so that issue is fixed in the core that it can not appear again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants