1
votes

I have 2 environments... a local development env running MAMP and and LAMP server shared by my development team for testing. Both environments are using the dev symfony environment (app_dev.php) and we have disabled assetic_controller. On our local setups, we are consistently able to make changes, run cache:clear and assetic:dump, and everything works as it should. On our shared environment (which we deploy to using magellanes) we end up with this odd scenario where the javascript files in our bundle's public/Resources/js get written to web/js with different filenames than what is referenced in the generated HTML where they are embedded.

So for example, in the twig template there is this:

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

What gets written in the html is:

<script type="text/javascript" src="/js/60d13ef_part_1_myscript_7.js"></script>

but what gets dumped to disk in web/js is:

60d13ef_part_1_myscript_6.js

The deployment steps (summarized) are like this:

  • Deploy via Git Rebase
  • Set global parameters for Symfony
  • Install vendors via Composer
  • Cache Clear
  • Assetic Dump
  • Cache Warmup
  • Release (manipulating symlinks)
  • Dump APC Cache

So what the heck am I doing wrong? Even when I go in after a deployment and manually clear the cache / run assetic:dump, the problem persists. Every once in a while we will deploy and it just works, but mostly, not. Also, it was working reliably for a while and then stopped. I am out of ideas for where to look to track down the issue.

1

1 Answers

0
votes

This looks like a bug. One of my JS files began with an uppercase letter, and the files were being sorted differently when being written to HTML than when being written to disk. I just filed the following bug report. Hope this helps someone:

Environment:

  • CentOS release 6.5 (Final)
  • Symfony 2.5
  • PHP 5.3.3

When referencing a whole directory of assets, eg. Resources/public/js/Default:

Ascript.js
bscript.js
cscript.js

like so:

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

What gets written in the html is:

<script type="text/javascript" src="/js/60d13ef_part_1_Ascript_1.js"></script>
<script type="text/javascript" src="/js/60d13ef_part_1_byscript_2.js"></script>
<script type="text/javascript" src="/js/60d13ef_part_1_cscript_3.js"></script>

But what is written to disk in web/js is:

60d13ef_part_1_bscript_1.js
60d13ef_part_1_cscript_2.js
60d13ef_part_1_Ascript_3.js

So all of the javascripts 404. Renaming Ascript.js to ascript.js resolves the issue.