8000 [RFC] Deprecate 'views' directory in favor of 'templates' everywhere · Issue #24227 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC] Deprecate 'views' directory in favor of 'templates' everywhere #24227

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

Closed
yceruto opened this issue Sep 15, 2017 · 5 comments
Closed

[RFC] Deprecate 'views' directory in favor of 'templates' everywhere #24227

yceruto opened this issue Sep 15, 2017 · 5 comments

Comments

@yceruto
Copy link
Member
yceruto commented Sep 15, 2017
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3.4, 4.0

The proposal, according to the new directory structure for 3.4/4.0 applications, deprecate:

  • AcmeBundle/Resources/views in favor of AcmeBundle/Resources/templates.
  • %kernel.root_dir%/Resources/views in favor of twig.default_path.
  • %kernel.root_dir%/Resources/<BundleName>/views in favor of templates/bundles/<BundleName>.

the last two are ready, but we have not done the deprecation notice in 3.4 if the old path exists and it is not added manually to the twig.paths list.

It would eliminate future confusion about two different names with the same concept within the Symfony world. Same modus operadi, deprecate in 3.4 and remove in 4.0.

What do you think?

@fabpot
Copy link
Member
fabpot commented Sep 15, 2017

I would not change that. New projects will use templates/ at the project's root. So, the paths you mentioned are somewhat "legacy" for end users. Now, for bundles, I don't think this is worth it as there is not really an easy upgrade path (one can create a symlink but that's not worth it if you ask me).

@yceruto
Copy link
Member Author
yceruto commented Sep 15, 2017

Thanks for your quick feedback :)

I would not change that. New projects will use templates/ at the project's root. So, the paths you mentioned are somewhat "legacy" for end users.

👍

Now, for bundles, ...

Same as new projects, new bundle will use Bundle/Resources/templates.

... I don't think this is worth it as there is not really an easy upgrade path (one can create a symlink but that's not worth it if you ask me).

For existing ones, the migration path should be quite easy IMHHO just need to rename views/ to templates/ directory and since the Twig's namespace remains the same it wouldn't affect the template load, but I'm probably missing something when you say there is not really an easy upgrade path.

@yceruto
Copy link
Member Author
yceruto commented Sep 16, 2017

This way you would see the bundles paths:
bundles-templates
I tried it for TwigBundle and it worked fine (without do anything more that rename the views directory) just adding:

if (file_exists($dir = $bundle['path'].'/Resources/templates')) {
    $bundleHierarchy[$name]['paths'][] = $dir;
}
$container->addResource(new FileExistenceResource($dir));

in TwigExtension.

@fabpot
Copy link
Member
fabpot commented Sep 16, 2017

You forget that a bundle must be able to support several versions of Symfony. So, it must work with views AND templates, not one or the other.

@yceruto
Copy link
Member Author
yceruto commented Sep 16, 2017

Sure, I forgot about that, nevermind.

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

No branches or pull requests

2 participants
0