Symfony 2 – Working with assets

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 of a bundle, you might have to, depending on your OS and which options you used when called assets:install If you’re using an OS which supports symlinks … Read more

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

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 access to the request … Read more

Symfony get Asset Name in Assetic output

Using Assetic to manage web assets in Symfony applications is no longer recommended. Instead, use Webpack Encore. https://symfony.com/doc/current/frontend/assetic/index.html#dumping-asset-files Page-Specific JavaScript or CSS (Multiple Entries) is described here: https://symfony.com/doc/current/frontend/encore/simple-example.html#multiple-javascript-entries // webpack.config.js Encore // … general CSS file here… .addStyleEntry(‘some_page’, ‘./assets/css/assetName.css’) ; Using addStyleEntry() is supported, but not recommended. A better option is to follow the pattern … Read more

Path of assets in CSS files in Symfony 2

I have came across the very-very-same problem. In short: Willing to have original CSS in an “internal” dir (Resources/assets/css/a.css) Willing to have the images in the “public” dir (Resources/public/images/devil.png) Willing that twig takes that CSS, recompiles it into web/css/a.css and make it point the image in /web/bundles/mynicebundle/images/devil.png I have made a test with ALL possible … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)