This question is more theoretical then practical. Let's say I have project based on PHP framework Symphony/Zend, I also use gulp for frontend work. I would like to do this project in professional way, so I use gulp plugins like jade, clean, uglify, minify, gzip, imagemin and rev. If someone doesn't know what is this gulp-rev, here we go:
Static asset revisioning by appending content hash to filenames unicorn.css → unicorn-d41d8cd98f.css
Good thing for caching static files for example.
So, here is a problem...
I run gulp tasks and I got following files:
- assets
- css
- style-bfd65634.css
- js
- vendor-mkg5454.js
- img
- background-ok54353.png
etc...
After I finish my frontend work I want to put it in PHP framework's view files (phtml files), example: layout.phtml
...
<link type="text/css" rel="stylesheet" media="screen" href="<?php echo $this->basePath(); ?>/assets/css/style-bfd65634.css">
...
<div id="logo">
<img src="<?php echo $this->basePath(); ?>/assets/img/background-ok54353.png" />
</div>
...
and same thing goes with js files, images etc.
After few weeks I have to change something in CSS styles and what now?
How can I re-run gulp tasks without need to change phtml files from PHP framework? Or do I have to change modified files manualy in EVERY phtml file?
If so, then what is a point to use such plugins like gulp-rev? Just for static websites? As far as I know there is not any plugin which would convert jade files to phtml with PHP tags
mostly yes.
To do the same thing with php you should use a wrapper function to display the resource asset url.
That wrapper function will take the relative url, match it to an actual file path, get the last update time of the file and append it to the returned url such
url/to/asset.some?l=<filemtime value>see http://php.net/manual/fr/function.filemtime.php
I must mention that an alternative way is to build your php file via the grunt build chain, see wiredep. But i do not recommend it. see https://github.com/stephenplusplus/grunt-wiredep