Skip to content

Explained the locateResource() method of HttpKernel #7909

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
wants to merge 4 commits into from

Conversation

javiereguiluz
Copy link
Member

This fixes #4065 and replaces #7479, which didn't explain the method inside the HttpKernel component docs.

Copy link
Contributor

@GuilhemN GuilhemN left a comment

Choose a reason for hiding this comment

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

LGTM 👍

files, etc.), don't use physical paths (e.g. ``__DIR__/config/services.xml``)
but logical paths (e.g. ``@AppBundle/Resources/config/services.xml``).

The logical paths are required beucase of the bundle overriding mechanism that
Copy link
Contributor

Choose a reason for hiding this comment

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

because

Resources
---------

If the bundle references any resources (config files, templates, translation
Copy link
Member

Choose a reason for hiding this comment

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

The notation explained here does not work for Twig templates.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm afraid I don't understand your comment.

Copy link
Member

@xabbuh xabbuh Jul 5, 2017

Choose a reason for hiding this comment

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

For Twig templates the namespace would be @App instead of @AppBundle. And furthermore, you would leave out the Resources/views portion of the template path (because Twig namespaces are not handled by the kernel resource locater but are a core feature of Twig itself).

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reworded this. I truly dislike that the logical path of templates is different than for the rest of resources. I understand that "old Symfony" used bundles everywhere and @App/Default/index.html.twig was more convenient than @AppBundle/Resources/views/Default/index.html.twig.

However, for Symfony 4 / Flex, which removes the concept of bundles for your own code, I think we should remove this difference and use the same syntax for everything.

lets you override any resource/file of any bundle. See :ref:`http-kernel-resource-locator`
for more details about transforming physical paths into logical paths.

Beware that templates use a simplified version of the logical path showed above.
Copy link
Member

Choose a reason for hiding this comment

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

shown

for more details about transforming physical paths into logical paths.

Beware that templates use a simplified version of the logical path showed above.
For example, a ``index.html.twig`` template located in the ``Resources/views/Default/``
Copy link
Member

Choose a reason for hiding this comment

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

an

@xabbuh
Copy link
Member

xabbuh commented Jul 7, 2017

Thank you Javier.

xabbuh added a commit that referenced this pull request Jul 7, 2017
…ereguiluz)

This PR was squashed before being merged into the 2.7 branch (closes #7909).

Discussion
----------

Explained the locateResource() method of HttpKernel

This fixes #4065 and replaces #7479, which didn't explain the method inside the HttpKernel component docs.

Commits
-------

b46ff01 Explained the locateResource() method of HttpKernel
xabbuh added a commit that referenced this pull request Jul 7, 2017
@xabbuh xabbuh closed this Jul 7, 2017
xabbuh added a commit that referenced this pull request Jul 7, 2017
* 2.7:
  [#7907] add some use statements
  Updating Doctrine syntax for getRepository method
  Updating doctrine class use
  [#7909] fix some typos
  Explained the locateResource() method of HttpKernel
  Reworded the note about dump() not being available in prod
  Symfony Installer Instructions for Windows
  Typo
  Fixing a typo in the Final Thoughts section
  Stop recommending the use of "doctrine:generate:entities"
  Added a help note about translating routes
  Use a safer code sample for Twig best practices
  Use the Twig namespaced syntax for all templates
xabbuh added a commit that referenced this pull request Jul 9, 2017
* 2.8:
  [#7907] add some use statements
  Updating Doctrine syntax for getRepository method
  Reworded the tip about property_info and Symfony framework
  remove useless space
  Add information for enable property_info service
  Updating doctrine class use
  [#7909] fix some typos
  Explained the locateResource() method of HttpKernel
  Reworded the note about dump() not being available in prod
  Symfony Installer Instructions for Windows
  Typo
  Fixing a typo in the Final Thoughts section
  Stop recommending the use of "doctrine:generate:entities"
  Added a help note about translating routes
  Use a safer code sample for Twig best practices
  Use the Twig namespaced syntax for all templates
  Updated the screenshot of deprecation messages
xabbuh added a commit that referenced this pull request Jul 9, 2017
* 3.2:
  [#7907] add some use statements
  Updating Doctrine syntax for getRepository method
  Reworded the tip about property_info and Symfony framework
  remove useless space
  Add information for enable property_info service
  Updating doctrine class use
  Fixed the parse() method in the ExpressionLanguage AST examples
  [#7909] fix some typos
  Explained the locateResource() method of HttpKernel
  Reworded the note about dump() not being available in prod
  Symfony Installer Instructions for Windows
  Typo
  Fixing a typo in the Final Thoughts section
  Stop recommending the use of "doctrine:generate:entities"
  Use "null" so the lock is named automatically
  Added a help note about translating routes
  Use a safer code sample for Twig best practices
  Use the Twig namespaced syntax for all templates
  Updated the screenshot of deprecation messages
  Update lockable_trait.rst
xabbuh added a commit that referenced this pull request Jul 9, 2017
* 3.3: (36 commits)
  [#7907] add some use statements
  Updating Doctrine syntax for getRepository method
  Reworded the tip about property_info and Symfony framework
  remove useless space
  Add information for enable property_info service
  Updating doctrine class use
  Fixed the parse() method in the ExpressionLanguage AST examples
  [#7909] fix some typos
  Explained the locateResource() method of HttpKernel
  Reworded the note about dump() not being available in prod
  Symfony Installer Instructions for Windows
  Updated the screenshot of exceptions in dev environment
  Typo
  Fixing a typo in the Final Thoughts section
  Stop recommending the use of "doctrine:generate:entities"
  Use "null" so the lock is named automatically
  incorrect session short description
  Use of Setters and Getters
  Small mistype edits
  Changed text how to get button label
  ...
xabbuh added a commit that referenced this pull request Jul 9, 2017
* 3.4: (23 commits)
  [#7907] add some use statements
  Updating Doctrine syntax for getRepository method
  Reworded the tip about property_info and Symfony framework
  remove useless space
  Add information for enable property_info service
  Updating doctrine class use
  Fixed the parse() method in the ExpressionLanguage AST examples
  [#7909] fix some typos
  Explained the locateResource() method of HttpKernel
  Reworded the note about dump() not being available in prod
  Symfony Installer Instructions for Windows
  Updated the screenshot of exceptions in dev environment
  Typo
  Fixing a typo in the Final Thoughts section
  Stop recommending the use of "doctrine:generate:entities"
  Use "null" so the lock is named automatically
  Added a help note about translating routes
  Use a safer code sample for Twig best practices
  Use the Twig namespaced syntax for all templates
  Updated the screenshot of deprecation messages
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants