{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/13234","labels_url":"https://api.github.com/repos/symfony/symfony/issues/13234/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/13234/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/13234/events","html_url":"https://github.com/symfony/symfony/pull/13234","id":53333325,"number":13234,"title":"[Asset] added the component","user":{"login":"fabpot","id":47313,"avatar_url":"https://avatars.githubusercontent.com/u/47313?v=3","gravatar_id":"","url":"https://api.github.com/users/fabpot","html_url":"https://github.com/fabpot","followers_url":"https://api.github.com/users/fabpot/followers","following_url":"https://api.github.com/users/fabpot/following{/other_user}","gists_url":"https://api.github.com/users/fabpot/gists{/gist_id}","starred_url":"https://api.github.com/users/fabpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabpot/subscriptions","organizations_url":"https://api.github.com/users/fabpot/orgs","repos_url":"https://api.github.com/users/fabpot/repos","events_url":"https://api.github.com/users/fabpot/events{/privacy}","received_events_url":"https://api.github.com/users/fabpot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-04T11:10:11Z","updated_at":"2015-01-06T01:32:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/13234","html_url":"https://github.com/symfony/symfony/pull/13234","diff_url":"https://github.com/symfony/symfony/pull/13234.diff","patch_url":"https://github.com/symfony/symfony/pull/13234.patch"},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | yes\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | yes\r\n| Tests pass?   | yes\r\n| Fixed tickets | #10973, #11748, #11876, #4883\r\n| License       | MIT\r\n| Doc PR        | not yet\r\n\r\nTODO:\r\n\r\n - [ ] submit documentation PR\r\n\r\nThe current Asset sub-namespace in Templating has several (major) problems:\r\n\r\n * It does not cover all use cases (see #10973 and #4883 for some example)\r\n * It has some design issues (relies on the Request instance and so requires the request scope, very coupled with the PHP templating sub-system, see #11748 and #11876)\r\n\r\nTo decouple this feature and make it reusable in Silex for instance, and to fix the design issues and make it more extensible, I've decided to extract and rework the features provided into a new Asset component.\r\n\r\nBasically, this component allows the developer to easily manage asset URLs: versioning, paths, and hosts.\r\n\r\nBoth the new and the old asset management features are kept in this PR to avoid breaking BC; the old system is of course deprecated and will be removed in 3.0. Keeping both system in parallel allow for an easier upgrade path for our users.\r\n\r\nTo make using both the old and the new systems possible in one application, the old `asset` Twig function has been renamed to `asset_path` and the configuration happens in `framework.assets` instead of `framework.templating.assets`.\r\n\r\nEven if the features are quite similar, and besides the flexilibity of the new system, here are some differences:\r\n\r\n * `PathPackage` always prepend the path (even if the given path starts with `/`).\r\n * Usage is stricter (for instance, `PathPackage` requires a basePath to be passed and `UrlPackage` requires that at least on URL is passed).\r\n * In the configuration, named packages inherits from the version and version format of the default package by default.\r\n * It is not possible to override the version when asking for a URL (instead, you can define your own version strategy implementation -- the use cases explained in #6092 are easily implemented this way).\r\n * It's not possible to generate absolute URLs (see #13264 for a better alternative using composition; so using `absolute_url(asset_path('me.png')) should work)`.\r\n\r\n#10973 was about adding shortcuts for bundles, which is a good idea; but given that you rarely reference built-in or third-party bundle assets and because we now have a one-bundle default approach named AppBundle, the same can be achieved with just a simple piece of configuration with the new assets feature:\r\n\r\n```yml\r\nframework:\r\n    assets:\r\n        packages:\r\n            app:\r\n                base_path: /bundles/app/\r\n            img:\r\n                base_path: /bundles/app/images/\r\n```\r\n\r\nThen:\r\n\r\n```jinja\r\n{{ asset_path('images/me.png', 'app') }}\r\n# /bundles/app/images/me.png\r\n\r\n{{ asset_path('me.png', 'img') }}\r\n# /bundles/app/images/me.png\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/68813249","html_url":"https://github.com/symfony/symfony/pull/13234#issuecomment-68813249","issue_url":"https://api.github.com/repos/symfony/symfony/issues/13234","id":68813249,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2015-01-06T01:32:55Z","updated_at":"2015-01-06T01:32:55Z","body":"I found the issue about making asset version work with absolute URLs. It is https://github.com/symfony/symfony/issues/12474"}}