The downloaded combine.php must be adjusted and all combined files must exist in the same folder.
Since the original solution was so slick, this was quite easy to achieve. I will not upload my solution, since I want you to grab the original code from rakaz.nl so that it receives the visitors it deserves 🙂
Let’s get started:
- In your project root, create a folder called
bundle(or whatever you want)
In the bundle folder, create an
.htaccessfile and add the following code:
- In the bundle folder, create a
combine.phpfile and add this content to it
Now you’re practically at where the original approach told you to adjust the PHP code a bit. Instead, do this:
$path = realpath($base . '/' . $element);
$path = "../" . $element
The code has to be replaced at two places in the PHP file, but all in all that’s it! The only thing you have to consider now, is to use application root relative paths when calling the bundle URL.
For instance, I have my main js folder in the application root folder content/js. Let’s say that I have the files a.js and b.js. The bundle URL would then be:
To bundle CSS files, the corresponding code would look like:
The newly added code will add a ../ to each link, before attempting to parse the file, which will still work great since the combine.php file is placed one level down from the application root, to which the links have to be relative, remember?
Another nice thing is that the .htaccess file is placed inside the bundle folder. This means that you can just copy the bundle folder, if you would like to use it in another project.
Hope this helps!