neilime/zf2-assets-bundle

Production environment does not work

wambaloo opened this issue · 5 comments

Hi !

When I try to set "production" to "true", URL generated for JS script is like "/jscustom/Entities/Controller/IndexController/manage?1476786158". This URL send a 404 error. I see that there is a router by default configured in AssetsBundle plugin, but I can't see what's the problem with it. I will search if I found a solution.

I've made a test, and everything isOK for me.
Can you post your layout head part with jsCustom implementation and the generated html.

Here is my header content :

<?php //Set time() force browser not to cache file, it's not mandatory if (!empty($this->jsCustomUrl)) { $this->plugin('InlineScript')->appendFile($this->jsCustomUrl . '?' . time()); } elseif (is_array($this->jsCustomFiles)) { foreach ($this->jsCustomFiles as $sJsCustomFile) { // Development case $this->plugin('InlineScript')->appendFile($sJsCustomFile); } } ?>

And what is generated in the body :

<script type="text/javascript" src="/jscustom/Dossier%5CController%5CIndexController/nonAffectedDossierList?1476797519"></script>

So I understand that it's not the header but the first line in the body who is problematic :
<?php echo $this->inlineScript() ?>

There was a mistake in the doc which has been fixed already, here is the right code :

if(!empty($this->jsCustomUrl)) {
    $this->plugin('HeadScript')->appendFile($this->jsCustomUrl.'?'.time()); // Set time() force browser not to cache file, it's not mandatory
}

Have you tried the snippet of code I suggest you ?

Yes sorry, it works perfectly !!! Ticket can be closed !

Thanks again for your reactivity !