Kuro
Kuro

Reputation: 868

Symfony2 Assetic generating dead links in dev

I'll try to keep it short, don't want to waste your time. Working in dev environment:

template:

{% block javascripts %}
   {% javascripts '@SomeBundle/Resources/public/js/*' %}
      <script type="text/javascript" src="{{ asset_url }}"></script>
   {% endjavascripts %}

{% endblock %}

html output:

<script type="text/javascript" src="/js/98b0881_part_1_fill_form.jquery_1.js"></script>                            
<script type="text/javascript" src="/js/98b0881_part_1_jquery-1.8.3.min_2.js"></script>

so it reads the contents of Resources/public/js dir and makes the correct number of links with the right names. When I click the given url however, i get 404 apache response:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
        <title>404 Not Found</title>
    </head><body>
    <h1>Not Found</h1>
    <p>The requested URL /js/98b0881_part_1_jquery-1.8.3.min_2.js was not found on this server.</p>
    <hr>
    <address>Apache/2.2.22 (Ubuntu) Server at ipardon.loc Port 80</address>
</body></html>

Which pretty much means no JS for me on my page. What have i tried:

app/console assets:install web --no-dev
app/console assetic:dump --no-dev

adding bundle name in config.yml to assetic.bundles[] googling ( of course )

Anyone encountered anything like this before? I have, and "solved" it by not using assetic, but I'd like to get it right this time. Any ideas?

Upvotes: 1

Views: 2320

Answers (2)

snyx
snyx

Reputation: 1104

as described here you can use

php app/console assetic:dump --watch

it will automatic dump your assets if they are changed.

this post hast also infos on that subject

Upvotes: 5

Inoryy
Inoryy

Reputation: 8425

In production you really only need to dump once per deployment, which can be automated (see Capifony).

In development don't use --no-dev parameters, this makes assetic dump compiled files only, ignoring the partial /js/98b0881_part_1_jquery-1.8.3.min_2.js

Upvotes: 1

Related Questions