2

Attempting to load in multiple js libraries. Using either method bellow, the bootstrap and facebook js files load in fine, but any other libraries I add either throw a 500 error if called by name or simply do not load in if using /* The files are all in the same directory with the same permissions as far as I can tell. Why would this be happening and how can I fix it?

Method 1:

{% javascripts
        'bundles/onnbrun/js/*'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

Method 2:

{% javascripts
        'bundles/onnbrun/js/jquery-1.8.0.min.js'
        'bundles/onnbrun/js/jquery-ui-1.9.0.js'
        'bundles/onnbrun/js/bootstrap.min.js'
        'bundles/onnbrun/js/facebook_enable.js'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

UPDATE #1:

Using the @Bundle syntax suggested below I am able to run php app/console assetic:dump without error; however, when I attempt to go to app_dev.php in a browser I get the error:

An exception has been thrown during the compilation of a template ("Unable to find file "@ONNBrunBundle/js/jquery-1.8.0.min.js".") in "ONNBrunBundle::web.html.twig".

I am able to view the file located in my bundle's Resources/public/js directory through my ide and through putty.

UPDATE #2:

On advice from lee in #symfony tried routing to my js directory in my browser and voila! only the two js files that have been serving properly the whole time are there - nothing else.

So... /www/src/ONN/BrunBundle/Resources/public/js shows me all the js files I'm trying to serve when I look at it through putty or through my ide or through any random ftp program; however, /web/bundles/onnbrun/js/ in a browser shows only the two js files that serve correctly.

I have run assetic:dump and assetic:dump --env=prod --no-debug with no errors.

I have run cache:clear.

I don't know what could be causing the discrepancy.

4
  • What's the error message? Commented Jan 27, 2013 at 8:31
  • try clearing the cachce and then try again Commented Jan 27, 2013 at 9:02
  • Have you dumped all of them? app/console assetic:dump Commented Jan 27, 2013 at 9:33
  • when I do the dump I get [error] The source file "/home/brun/www/app/../web/bundles/onnbrun/js/jquery-1.8.0.min.js" does not exist. but I see the file in the directory. Commented Jan 27, 2013 at 10:25

1 Answer 1

3

case 1)

your files are stored in a bundle

If it's the case, use the code below

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

case 2)

Your files are stored in your root web directory under a js directory (not a bundle directory)

{% javascripts
        'js/*'
        %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

Final step

dump your file

php app/console assetic:dump --env=prod --no-debug
Sign up to request clarification or add additional context in comments.

5 Comments

When using the @Bundle syntax there's basically no change. Obviously no error is thrown at dump if I use --no-debug, but if I just run php app/console assetic:dump it says: [RuntimeException] The source file "/home/brun/www/app/../web/bundles/onnbrun/js/jquery-1.8.0. min.js" does not exist. And attempting to go to the template in a browser produces the error: An exception has been thrown during the compilation of a template ("Unable to find file "@ONNBrunBundle/js/jquery-1.8.0.min.js".") in "ONNBrunBundle::web.html.twig
I needed to be running php app/console cache:clear between each trouble shooting attempt - that's probably half my problem. When I use the @Bundle syntax then clear the cache and then try php app/console assetic:dump it runs clean, but then I still get the Unable to find file error when attempting to go to the template in a browser. Why?
The two working files were a red herring; they weren't really being served by assetic, they'd been plugged in manually months ago. redid the whole thing, works beautifully now.
great, be sure to dump assetics on prod, you dont need on dev (by default)
Your explanation on both cases was exactly what I was looking for. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.