One of most asked questions and I didn't find answer.
I had tried with
php app/console assets:install web --symlink
and
php app/console assets:install --symlink
In project I work currently, there is 4 bundles and using suggested /web folder for assets is not in option. Also I had tried
asset('@Bundle/Resources/public/images/image.png')
I must notice that this '@Bundle/Resources/public/...'
worked for calling assets in block
{% block stylesheets %}
{{ parent() }}
{% stylesheets
'@Bundle/Resources/public/css/some.css'
filter='cssrewrite' output='css/compiled.app.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" xmlns="http://www.w3.org/1999/html"/>
{% endstylesheets %}
{% endblock %}
but when tried "asset('...')"
I got error undefined assets.
I just study this:
http://symfony.com/doc/current/assetic/asset_management.html
and solve problem with images using symfony image tag
{% image '@AppBundle/Resources/public/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example" />
{% endimage %}
Also assets bundles is founding in web/bundles
folder after executing command assets:install --symlink
and there you can see lowercase asset bundle name in example AppTestBundle
will be just apptest