Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel][FrameworkBundle] Add alternative convention for bundle directories#32845

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:4.4fromyceruto:bundle_paths
Aug 13, 2019

Conversation

@yceruto
Copy link
Member

@ycerutoyceruto commentedAug 1, 2019
edited
Loading

QA
Branch?4.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#32453
LicenseMIT
Doc PRTODO

We already know that bundles must be compatible with many Symfony's versions, so it is very likely that current bundles won't be able to use this feature soon, unless they create symbolic links to support both structures.

The point is that this is already happening, so in the future when our bundles stop to support <=4.3 then you'll be sure to change the current directory structure.

We have recently added thegetPublicDir() method in#31975, here I'm removing it in favor of hardcoding a new convention.

I've added some functional tests in which I've changed everything to this structure:

-- ModernBundle   |-- config/    |-- public/   |-- src/       |-- ModernBundle.php   |-- templates/   |-- translations/

WDYT?

linaori and sstok reacted with thumbs up emojisstok reacted with eyes emoji
@nicolas-grekas
Copy link
Member

As I wrote in#32453 (comment), I'm not sure we want to make dirs configurable. Even getPublicDir is suspicious to me.

@linaori
Copy link
Contributor

I think making them configurable isn't necessarily what I want, it's the confusing structure it has right now I'd like to change. Making dirs configurable is one way to do this, because it means I don't have to follow the current structure and that it provides a migration path to change the default.

I very much prefer the structure as shown in the example. The fact that the non-code directory is called "Resources" (mind you, capital R) is bothering me since the start. the "views" directory isn't named correctly anymore either as it's called "templates" in Symfony.

Not sure if the proposed API is a good idea, but I do think that the bundle is responsible for the exposure of certain directories.

  • "Hey Symfony, you can find templates in this directory!"
  • "Hey, this directory contains entities, if you use doctrine, please register this"
  • etc.

Symfony telling where everything should be feels like something we could change, though it should have sane defaults. I don't agree with the current structure being a sane default anymore due to the changes in the Symfony structure;app/Resources vsbundle/Resources.

sstok reacted with thumbs up emoji

@ro0NL
Copy link
Contributor

ro0NL commentedAug 1, 2019
edited
Loading

what if we create a single entrypoint similar likeKernel, e.g.$bundle->locateResource(BundlePaths::CONFIG_DIR[, 'validator.yaml'])

with a built-in deprecation forviews in favor oftemplates

for DI extensions we should also consider injecting the config dir somehow, or access to any path for that matter

@yceruto
Copy link
MemberAuthor

As I wrote in#32453 (comment), I'm not sure we want to make dirs configurable. Even getPublicDir is suspicious to me.

I'm fine if it's not configurable, but we still want a new bundle directory structure, do you want it too?

with a built-in deprecation for views in favor of templates

@ro0NL we shouldn't deprecating yet ->... bundles must be compatible with many Symfony's versions. at least until we're sure we can all migrate to the new structure without any compatibility issue.

for DI extensions we should also consider injecting the config dir somehow, or access to any path for that matter

I'm not sure it's necessary, you can hardcode it safely there, it's in userland.

@nicolas-grekas
Copy link
Member

we still want a new bundle directory structure, do you want it too

yes! that'd look consistent with the new directory structure of apps

I'd just do it inFrameworkExtension only (and remove/deprecate getPublicDir)

@ycerutoyceruto changed the title[HttpKernel][FrameworkBundle] Add new method for bundle paths configuration[HttpKernel][FrameworkBundle] Add alternative convension for bundle directoriesAug 1, 2019
@ycerutoyceruto changed the title[HttpKernel][FrameworkBundle] Add alternative convension for bundle directories[HttpKernel][FrameworkBundle] Add alternative convention for bundle directoriesAug 1, 2019
@yceruto
Copy link
MemberAuthor

yceruto commentedAug 1, 2019
edited
Loading

Update

Removed the configuration of the bundle directory, it is now a new convension that we can optionally use as of 4.4 version.

AddedgetBundleDir method to the Bundle class, which is intended to define the root directory of the bundle. It may differ from the directory where theBundle.php file is located (akagetPath()), e.g. when we have the new structuresrc/Bundle.php then->getBundleDir() is a folder higher up.

The current convention is not being obsolete yet, it will (in the future).

Convention from 3rd-party bundles like Doctrine (/Resources/config/doctrine) must progressively support the new method in order to finally be able to deprecating/remove the old structure.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

I really like this approach :)
What's the purpose of getPath now? Should we deprecated it? Or should we plan to deprecate it in 5.1, to help bundles migrate smoothly?

@yceruto
Copy link
MemberAuthor

What's the purpose of getPath now? Should we deprecated it? Or should we plan to deprecate it in 5.1, to help bundles migrate smoothly?

I think that as of 5.2 (NOV 2020) where we should start to deprecating the legacy structure as well. That'll match with the end of support for 3.4.

nicolas-grekas and sstok reacted with thumbs up emoji

@yceruto
Copy link
MemberAuthor

Sorry for the rebasing after the approved revisions, I needed to update my PhpUnit bridge to make my local phpunit work properly.

Status: This Is Ready In My Side ;)

@ycerutoycerutoforce-pushed thebundle_paths branch 4 times, most recently from5de3197 to12c4c16CompareAugust 13, 2019 13:28
@nicolas-grekas
Copy link
Member

Thank you@yceruto.

@nicolas-grekasnicolas-grekas merged commit6996e1c intosymfony:4.4Aug 13, 2019
nicolas-grekas added a commit that referenced this pull requestAug 13, 2019
…on for bundle directories (yceruto)This PR was squashed before being merged into the 4.4 branch (closes#32845).Discussion----------[HttpKernel][FrameworkBundle] Add alternative convention for bundle directories| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#32453| License       | MIT| Doc PR        | TODOWe already know that bundles must be compatible with many Symfony's versions, so it is very likely that current bundles won't be able to use this feature soon, unless they create symbolic links to support both structures.The point is that this is already happening, so in the future when our bundles stop to support <=4.3 then you'll be sure to change the current directory structure.We have recently added the `getPublicDir()` method in#31975, here I'm removing it in favor of hardcoding a new convention.I've added some functional tests in which I've changed everything to this structure:```-- ModernBundle   |-- config/   |-- public/   |-- src/       |-- ModernBundle.php   |-- templates/   |-- translations/```WDYT?Commits-------6996e1c [HttpKernel][FrameworkBundle] Add alternative convention for bundle directories
@ycerutoyceruto deleted the bundle_paths branchAugust 13, 2019 13:30
@yceruto
Copy link
MemberAuthor

Yujuuu!! 🎉

javiereguiluz, sstok, and nicholasruunu reacted with hooray emoji

@anyt
Copy link

anyt commentedJan 8, 2020

Hi,

Bundle::getPublicDir() method ismentioned in the documentation but it'snot used.

Are there any plans to introduce the function back or remove it from documentation?

@yceruto
Copy link
MemberAuthor

Are there any plans to introduce the function back or remove it from documentation?

Yes, it should be removed from the documentation (leftover of#31975)

javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJan 12, 2020
This PR was merged into the 4.4 branch.Discussion----------remove getPublicDir() documentationseesymfony/symfony#32845 (comment)Commits-------e3fa2e6 remove getPublicDir() documentation
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestFeb 18, 2021
…e (yceruto)This PR was squashed before being merged into the 4.4 branch.Discussion----------Promoting new bundle directory structure as best practiceAs Symfony 3.4 is not currently supported (security fixes only) I would like to propose to start promoting the new bundle directory structure (compatible since 4.4) consistent with the project one.What do you think?Fix:#12156PR:symfony/symfony#32845Commits-------d44bfa8 Promoting new bundle directory structure as best practice
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dunglasdunglasAwaiting requested review from dunglas

@xabbuhxabbuhAwaiting requested review from xabbuh

+3 more reviewers

@ro0NLro0NLro0NL left review comments

@TaluuTaluuTaluu approved these changes

@TobionTobionTobion approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

9 participants

@yceruto@nicolas-grekas@linaori@ro0NL@Tobion@fabpot@anyt@Taluu@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp