assetic

Symfony2 Assetic get asset urls from inside controller, not template

安稳与你 提交于 2019-11-29 11:51:02
问题 I want to include the url to one of the assets in my bundle in the controller, not in the template. More specifically, but not very important: I make a HighChart chart using obHighChartsBundle, and I have to plot some special icons in some points of the graph I am producing. Therefore I need the url to the icon, which is in my bundle's asset folder. Is it possible to call some kind of asset manager from the controller and get the correct url to this asset? 回答1: You can call ($packageName is

How to get the full url for an asset in Controller?

…衆ロ難τιáo~ 提交于 2019-11-28 15:58:23
I need to generate some JSON content in controller and I need to get the full URL to an uploaded image situated here : /web/uploads/myimage.jpg . How can I get the full url of it? http://www.mywebsite.com/uploads/myimage.jpg You can generate the url from the request object: $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath(); You could make a twig extension that cuts the /web part of your path and uses the request to generate the base url. see Symfony\Component\Routing\Generator\UrlGenerator::doGenerate for a more solid implementation. Also, Twig has

AsseticBundle removed from all the Symfony's versions

北城以北 提交于 2019-11-28 14:12:20
问题 I wanted to know why AsseticBundle has been removed from all the versions of Symfony. I looked everywhere and I don't found any site talking about this news that began for some weeks. Initially, I thought they deleted this Bundle because there is a security flaw that will take a few days to be repaired. This Bundle is indisponsable for including javascript and css file type from an external folder and I wanted to be sure if this Bundle wille be replaced by an another in Symfony or I should

Symfony 2 - Working with assets

瘦欲@ 提交于 2019-11-28 03:49:34
I need some tips on how to work with assets in Symfony 2. For example, do we have to always perform the assets:update every time an image is added ? I know Assetic take care of the management on css and javascript files but what about images? What would be the best practice for the front-end development with Symfony 2 ? How do you guys setup your css, images and js files in your app to make it easy to develop, deploy and change ? Regarding images, if you added it into your public folder, I think there's no need to perform assets:update However, if you add the image within the resources folders

Difference between assetic:dump and assets:install

孤街醉人 提交于 2019-11-28 02:54:46
In Symfony2, what is the difference between assetic:dump and assets:install ? In what scenarios should each of these commands be used, and in what order (if order is relevant)? I actually wrote about this recently in an article about OroCRM, which is based on Symfony 2. If you want some of the context/why of the different commands, you might find it interesting. There are two different systems for including frontend files (javascript, css, images, etc.) in a Symfony application. The assets:install command came first. This command will search all the Symfony Bundles in an application for a

Pass a variable to an Assetic asset URL in Symfony2

白昼怎懂夜的黑 提交于 2019-11-27 23:38:44
Is there a way to pass a variable to the Assetic method in templates {% stylesheets '@SomeExampleBundle/Resources/views/ SOMEVAR /css/*' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} So what I want to do is pass SOMEVAR from the controller. Matt For now, I don't think it is possible at all. The reason behind this is that Assetic is run upfront to dump the assets, so it does not run the Twig template to compute the variable. This is probably the same if you do it in a PHP template. This means that runtime variables will not be computed and expanded. Thus, this make it

Symfony2 - Assetic - css font icons

混江龙づ霸主 提交于 2019-11-27 22:30:05
How to include css font icon libraries istalled via composer in /vendor dir (fontawesome for example). Include: {% stylesheets filter='cssrewrite' '%kernel.root_dir%/../vendor/fortawesome/font-awesome/css/font-awesome.min.css' %} <link href="{{ asset_url }}" type="text/css" rel="stylesheet"/> {% endstylesheets %} But it does't rewrite font files url, it stays same, and icons wont load: src: url('../fonts/fontawesome-webfont.eot?v=4.0.3'); I know, we can't make urls poined outside of webroot, but maybe assetic can put this dependencies to /web automatically? The only way I see for now is to

How to have Assetic + sass work with Symfony2 in Windows?

夙愿已清 提交于 2019-11-27 13:57:48
问题 I'm trying to get Assetic to run within Symfony 2.0.11 in order to use sass for css files. I've been fiddling around that issue for hours, and from what I gather the current assetic version (1.0.2) is screwed up and just can't work in windows. I tried updating assetic and asseticBundle to the latest Master version from github, but those require Symfony 2.1 which brings in a lot of changes and is not backward compatible (not to mention it's not officially released either), so that's not an

With Assetic / Twig / Symfony2, can I define front end libraries?

你说的曾经没有我的故事 提交于 2019-11-27 12:15:33
I'm using Symfony2, with Assetic and Twig. I have various frontend libraries - Backbone, jQuery, jQuery UI, and Bootstrap. Both Bootstrap and jQuery UI include CSS and JS files. Is there a way that I can define the resources they need to include (including dependencies), and then in Twig / Assetic just include all those resources in one tag? What I'd look to have is something like: // config.yml <!-- DOES NOT WORK --> assetic: resources: jquery: js: /filepath/to/jquery.js jquery_ui: dependencies: jquery css: /filepath/to/jqueryui.css js: /filepath/to/jqueryui.js less: js: /filepath/to/less.js

Combining Assetic Resources across inherited templates

烂漫一生 提交于 2019-11-27 12:05:39
We are building a new site using Symfony2, and Assetic looks very promising for resource management, in particular for combining and processing all js/css files together automatically. We wil have some resources that are used site wide, and some that are specific to particular pages. We will also be using a three tiered inherited approach to templates. Is there a way to combine the two concepts, i.e. to automatically add additional resources in inherited templates so that they are all output as a single resource? Nemanja Miljković Unfortunately, you can't :( You can't override the assetic tags