In the last entry I was mentioning several solutions for managing web site deployments and packaging for php webapps. Since with PHP there is usually no build process already at development time this has often to be established especially for test & production – and yes there needs to be a build process if you do serious php web development.
Despite Sprocket or similar tools I decided to go for the plain old ANT approach. Why? It was the most practical tool, you have full control of what you are doing and the other tools did not quite what I wanted.
One part of this ant solution was to configure production setting in several source files. I rediscovered just how powerful and really simple this great tool is. Once you get used to is configure,combine,pack and deploy your php/js/html/css is a piece of cake:
Here some excerpts
In order to have just one source file I defined some custom preprocessor variables in my various files:
<echomessage="Configuring PHP config for production"/><replaceregexpbyline="true"flags="m"><regexppattern="^.*@@dev@@.*$"/><substitutionexpression=""/><filesetdir="${build.dir}"><includename="php/config/*.php"/></fileset></replaceregexp><replaceregexpbyline="true"flags="m"><regexppattern="^.*@@prod@@(.*)$"/><substitutionexpression="\1"/><filesetdir="${build.dir}"><includename="php/config/*.php"/></fileset></replaceregexp>
And for the javascript in my php – view files
<echomessage="Configuring referenced Javascript for production"/><replaceregexpflags="sg"><regexppattern="@@js-dev-start@@[^\@]*@@js-dev-end@@"/><substitutionexpression=""/><filesetdir="${build.dir}/php/view"><includename="**/*.php"/></fileset></replaceregexp><replaceregexpbyline="true"flags="m"><regexppattern="^.*@@js-prod-start@@(.*)@@js-prod-end@@.*$"/><substitutionexpression="\1"/><filesetdir="${build.dir}/php/view"><includename="**/*.php"/></fileset></replaceregexp>
Applying the concat task for js and css concatenation and apply java to invoke the yuicompressor and you’re done.
Website deployments: Plain old Ant
In the last entry I was mentioning several solutions for managing web site deployments and packaging for php webapps. Since with PHP there is usually no build process already at development time this has often to be established especially for test & production – and yes there needs to be a build process if you do serious php web development.
Despite Sprocket or similar tools I decided to go for the plain old ANT approach. Why? It was the most practical tool, you have full control of what you are doing and the other tools did not quite what I wanted.
One part of this ant solution was to configure production setting in several source files. I rediscovered just how powerful and really simple this great tool is. Once you get used to is configure,combine,pack and deploy your php/js/html/css is a piece of cake:
Here some excerpts
In order to have just one source file I defined some custom preprocessor variables in my various files:
then in ant this looks as follows:
And for the javascript in my php – view files
Applying the concat task for js and css concatenation and apply java to invoke the yuicompressor and you’re done.