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

Appearance settings

Added "How to Use a Custom Version Strategy for Assets" #7141

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

Merged
merged 12 commits into from
Dec 12, 2016

Conversation

javiereguiluz
Copy link
Member

This PR finishes the great work made by @teohhanhui in #5489.

@stof
Copy link
Member

stof commented Nov 15, 2016

you should also fix conflicts

@javiereguiluz javiereguiluz force-pushed the pr/5489 branch 2 times, most recently from 6bc5efb to c59cff6 Compare November 15, 2016 09:46
:ref:`version <reference-framework-assets-version>` and
:ref:`version_format <reference-framework-assets-version-format>` configuration
options. If your application requires a more advanced versioning, you can create
your own version strategy.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add an example here, what "requires a more advanced versioning" means?

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 part a bit. Thanks.

Asset version strategies are PHP classes that implement the
:class:`Symfony\\Component\\Asset\\VersionStrategy\\VersionStrategyInterface`.
In this example, the constructor of the class takes as arguments the path to
the manifest file generated by gulp-buster and the format of the generated
Copy link
Contributor

Choose a reason for hiding this comment

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

gulp buster should be a link here, too

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -93,6 +93,8 @@ Returns an instance of ``ControllerReference`` to be used with functions
like :ref:`render() <reference-twig-function-render>` and
:ref:`render_esi() <reference-twig-function-render-esi>`.

.. _reference-twig-function-asset:
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you add this here @javiereguiluz ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. It was in the original PR. I've just removed it.


Finally, enable the new asset versioning for all the application assets or just
for some :ref:`asset package <reference-framework-assets-packages>` thanks to
the :ref:`version_strategy <reference-framework-assets-version_strategy>` option:
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you have to add a label for this.

Asset versioning is a technique that improves the performance of web
applications by adding a version identifier to the URL of the static assets
(CSS, JavaScript, images, etc.) When the content of the asset changes, its
identifier is also modified to force the browser download it again instead of
Copy link
Member

Choose a reason for hiding this comment

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

[...] the browser to download it [...]


private function loadManifest(array $options)
{
$hashes = json_decode(file_get_contents($this->manifestPath), true);
Copy link
Member

Choose a reason for hiding this comment

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

The variable is not needed.

Register the Strategy Service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After creating the strategy PHP class, register it as a Symfony service
Copy link
Member

Choose a reason for hiding this comment

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

Missing colon at the end of the sentence.

http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:assets version_strategy="app.assets.versioning.gulp_buster" />
Copy link
Member

Choose a reason for hiding this comment

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

In XML, the attribute should be version-strategy.


**type**: ``string`` **default**: null

The service id of the :doc:`asset version strategy </frontend/custom_version:strategy>`
Copy link
Member

Choose a reason for hiding this comment

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

The colon in the path would be an underscore.

@javiereguiluz
Copy link
Member Author

@xabbuh thanks for your review. I've fixed everything.

@@ -1013,6 +1016,7 @@ Each package can configure the following options:
* :ref:`base_urls <reference-assets-base-urls>`
* :ref:`version <reference-framework-assets-version>`
* :ref:`version_format <reference-assets-version-format>`
* :ref:`version_strategy <reference-assets-version-strategy>`
Copy link
Member

Choose a reason for hiding this comment

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

I guess this should be reference-framework-assets-version_strategy instead (see the build failure on Travis CI).

@xabbuh
Copy link
Member

xabbuh commented Dec 9, 2016

👍

Status: Reviewed

@xabbuh
Copy link
Member

xabbuh commented Dec 12, 2016

Thank you Javier.

@xabbuh xabbuh merged commit 1399967 into symfony:2.7 Dec 12, 2016
xabbuh added a commit that referenced this pull request Dec 12, 2016
…teohhanhui, javiereguiluz)

This PR was merged into the 2.7 branch.

Discussion
----------

Added "How to Use a Custom Version Strategy for Assets"

This PR finishes the great work made by @teohhanhui in #5489.

Commits
-------

1399967 Fixed a label name
981e82d Misc fixes
a02f3b3 Added the version_strategy option to the config reference
2830ba0 Added the missing doc label
482fda5 Minor rewords and fixes
f038483 Removed an unneeded change
ab8fa54 Fixed a rebase error
c59cff6 Moved the article to its new location
5971ce0 Removed an unneeded file
40dff64 Minor updates to the doc and service config
80d0ca2 Simplified the intro
4f530d8 Cookbook entry: Asset - Custom Version Strategy
@xabbuh
Copy link
Member

xabbuh commented Dec 12, 2016

And thank you for starting this awesome PR @teohhanhui!

xabbuh added a commit that referenced this pull request Dec 13, 2016
…ssets" (teohhanhui, javiereguiluz)"

This reverts commit d691f6e, reversing
changes made to 98e90a2.
xabbuh added a commit that referenced this pull request Dec 13, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

Revert the merge of #7141

I shouldn't have merged #7141 into the `2.7` branch as the related code PR (symfony/symfony#17532) was released with Symfony 3.1.

Commits
-------

0f7c7d5 Revert "minor #7141 Added "How to Use a Custom Version Strategy for Assets" (teohhanhui, javiereguiluz)"
xabbuh added a commit that referenced this pull request Dec 13, 2016
* 2.7:
  Revert "minor #7141 Added "How to Use a Custom Version Strategy for Assets" (teohhanhui, javiereguiluz)"
xabbuh added a commit that referenced this pull request Dec 13, 2016
* 2.8:
  Revert "minor #7141 Added "How to Use a Custom Version Strategy for Assets" (teohhanhui, javiereguiluz)"
xabbuh added a commit that referenced this pull request Dec 13, 2016
* 3.1:
  Revert "minor #7141 Added "How to Use a Custom Version Strategy for Assets" (teohhanhui, javiereguiluz)"
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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.