Skip to content
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

[make:controller] avoid require doctrine/annotation when can use attributes #858

Merged

Conversation

Jibbarth
Copy link
Contributor

@Jibbarth Jibbarth commented Apr 1, 2021

Hi makers 👋 !

This PR allows to make controller when we can use PHP8 attributes without forcing to install doctrine/annotation

But we should be aware that currently, without doctrine/annotation, we don't have a nice flex recipe that enable routing annotation read on Controller folder.

See symfony/recipes#916 for reference.

So maybe we should create the config/routes/annotation.yaml in case we can use attributes AND file does not exist ? WDYT ?

if (null === $phpCompatUtil) {
$phpCompatUtil = new PhpCompatUtil($fileManager);

trigger_deprecation('symfony/maker-bundle', '1.31', 'Initializing MakeController without providing an instance of PhpCompatUtil is deprecated.');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is heavily inspired on https://github.com/symfony/maker-bundle/blob/main/src/Generator.php#L40, tell me if it's not needed in this case

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it is worth it. When maker-bundle will require PHP 8 as a minimum version, we'll most likely drop the dependency to PhpCompatUtil, so in my opinion it's not useful to make this dependency mandatory.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for the deprecation here. PhpCompatUtil is internal & MakeController is final - I don't see a use case where someone would use a version >=1.31 and not be able to initiate MakeController w/o the utility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecation removed 👌

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

Thanks @Jibbarth This PR will have to wait for the resolution of symfony/recipes#916 before it can be merged.

So maybe we should create the config/routes/annotation.yaml in case we can use attributes AND file does not exist ? WDYT ?

I'm not a fan of this idea. That responsibility falls on recipes / flex in my opinion.

if (null === $phpCompatUtil) {
$phpCompatUtil = new PhpCompatUtil($fileManager);

trigger_deprecation('symfony/maker-bundle', '1.31', 'Initializing MakeController without providing an instance of PhpCompatUtil is deprecated.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for the deprecation here. PhpCompatUtil is internal & MakeController is final - I don't see a use case where someone would use a version >=1.31 and not be able to initiate MakeController w/o the utility.

@jrushlow jrushlow changed the title [controller] avoid require doctrine/annotation when can use attributes [make:controller] avoid require doctrine/annotation when can use attributes Apr 5, 2021
@jrushlow jrushlow added the Status: Needs Work Additional work is needed label Apr 5, 2021
@Jibbarth Jibbarth force-pushed the feature/remove-need-for-doctrine-annotation branch from 4d63ab8 to 37472d7 Compare April 10, 2021 16:22
@jrushlow jrushlow force-pushed the feature/remove-need-for-doctrine-annotation branch from 37472d7 to abbfa18 Compare May 3, 2022 21:42
Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

Thank you @Jibbarth! we can finally get this merged in!

@jrushlow jrushlow added Feature New Feature Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Work Additional work is needed labels May 3, 2022
@jrushlow
Copy link
Collaborator

jrushlow commented May 3, 2022

Note: To preserve BC, doctrine/annotations is still required for Symfony 5.4 IF the MakeController::class is used w/o passing an instance of PhpCompatUtil::class via the constructor.

@jrushlow jrushlow merged commit 4028f85 into symfony:main May 4, 2022
@jrushlow jrushlow mentioned this pull request May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants