This PR was merged into the 2.7 branch. Discussion ---------- [Asset] added the component | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #10973, #11748, #11876, #4883, #12474 | License | MIT | Doc PR | not yet TODO: - [ ] submit documentation PR The current Asset sub-namespace in Templating has several (major) problems: * It does not cover all use cases (see #10973 and #4883 for some example) * 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) To 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. Basically, this component allows the developer to easily manage asset URLs: versioning, paths, and hosts. Both 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 automatically converted to the new one. Even if the features are quite similar, and besides the flexilibity of the new system, here are some differences: * `PathPackage` always prepend the path (even if the given path starts with `/`). * Usage is stricter (for instance, `PathPackage` requires a basePath to be passed and `UrlPackage` requires that at least on URL is passed). * In the configuration, named packages inherits from the version and version format of the default package by default. * 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). * 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)`. #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: ```yml framework: assets: packages: app: base_path: /bundles/app/ img: base_path: /bundles/app/images/ ``` Then: ```jinja {{ asset('images/me.png', 'app') }} # /bundles/app/images/me.png {{ asset('me.png', 'img') }} # /bundles/app/images/me.png ``` #12474 discussed the possibility to add a version for absolute URL. It's not possible to do that in a generic way as the version strategy involves both the version and the path, which obviously cannot work when the path is an absolute URL already. Instead, one should use the `asset_version` Twig function to add the version manually. Commits ------- |
||
---|---|---|
src/Symfony | ||
.editorconfig | ||
.gitignore | ||
.travis.yml | ||
autoload.php.dist | ||
CHANGELOG-2.2.md | ||
CHANGELOG-2.3.md | ||
CHANGELOG-2.4.md | ||
CHANGELOG-2.5.md | ||
CHANGELOG-2.6.md | ||
composer.json | ||
CONTRIBUTING.md | ||
CONTRIBUTORS.md | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
UPGRADE-2.1.md | ||
UPGRADE-2.2.md | ||
UPGRADE-2.3.md | ||
UPGRADE-2.4.md | ||
UPGRADE-2.5.md | ||
UPGRADE-2.6.md | ||
UPGRADE-2.7.md | ||
UPGRADE-3.0.md |
README
What is Symfony?
Symfony is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.
Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.
Requirements
Symfony is only supported on PHP 5.3.9 and up.
Be warned that PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to run Symfony (https://bugs.php.net/bug.php?id=62715)
Installation
The best way to install Symfony is to download the Symfony Standard Edition available at http://symfony.com/download.
Documentation
The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony can help speed up your development and take the quality of your work to the next level, read the official Symfony documentation.
Contributing
Symfony is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.
Running Symfony Tests
Information on how to run the Symfony test suite can be found in the Running Symfony Tests section.