I would like to configure apache php5 in a way that
- .css and .js files will be inspected by php
I need this because both CSS and JS files are using global PHP vars. This allows me from a single PHP file to control both CSS and JS code dynamically (then the project is exported so that css and js files contain the actual values and not the PHP echos).
The way I’m doing right now is that I added .css and .js extension to apache php5.conf:
AddType application/x-httpd-php .php .phtml .php3 .css .js
I also use header(‘Content-Type: […]’) on top of each css/js file to change the Content-Type header value back to original. This isn’t ideal as I have to manually add this line to every css/js file in order for the Content-type header to be appropriate, even if I do not use the PHP global vars.
So anyway I can make PHP inspect css/js files while keeping their original Content-Type without having to modify the actual css/js files themselves?
I didn’t try that, but from the docs it looks possible:
/pseudostatic/css/somefilename.js by a certain controller, which would take a template based on the name of a requested file, prepend all the needed global variables to it and serve it with a needed header.
And I would use caching based on the file’s timestamp.