neilime / zf2-assets-bundle

AssetsBundle is a module for Zend Framework 2 allowing asset managment (bundling & caching)
https://neilime.github.io/zf2-assets-bundle/
MIT License
33 stars 20 forks source link

Production environment does not work #55

Closed wambaloo closed 7 years ago

wambaloo commented 7 years ago

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.

neilime commented 7 years ago

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

wambaloo commented 7 years ago

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() ?>

neilime commented 7 years ago

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
}
neilime commented 7 years ago

Have you tried the snippet of code I suggest you ?

wambaloo commented 7 years ago

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

Thanks again for your reactivity !