Skip to content

Instantly share code, notes, and snippets.

@bastman
Created October 8, 2013 16:29
Show Gist options
  • Save bastman/6887409 to your computer and use it in GitHub Desktop.
Save bastman/6887409 to your computer and use it in GitHub Desktop.
phing example tasks
project.environment.name=local
project.name=${phing.project.name}
dir.build_xml=${project.basedir}
project.host.default=${project.environment.name}.${project.name}.mydomain.com
dir.project=${dir.build_xml}/../../..
dir.project.application=${dir.project}/application
dir.project.bin=${dir.project}/bin
dir.project.build=${dir.project}/build
dir.project.etc=${dir.project}/etc
dir.project.console=${dir.project}/console
dir.project.vendor=${dir.project}/vendor
dir.project.build.phing=${dir.project.build}/phing
dir.project.build.phing.tmp=${dir.project.build.phing}/tmp
dir.project.build.application=${dir.project.build}/application
dir.project.build.application.php=${dir.project.build.application}/php
php.application.config.ini=${dir.build_xml}/php_application_config.ini
php.application.config.parsed.ini=${dir.project.build.application.php}/config.ini
php.application.config.json=${dir.project.build.application.php}/config.json
cmd.ini2json=php ${dir.project.bin}/ini2json.php
cmd.vhost_create=cpUtil.sh createVhost
url.composer.download=https://getcomposer.org/installer
dir.composer.bin=/usr/local/bin
cmd.composer=composer.phar
url.phpunit.download=https://phar.phpunit.de/phpunit.phar
dir.phpunit.bin=/usr/local/bin
cmd.phpunit=phpunit
url.phpunit-skelgen.download=https://phar.phpunit.de/phpunit-skelgen.phar
dir.phpunit-skelgen.bin=/usr/local/bin
cmd.phpunit-skelgen=phpunit-skelgen
<project name="helloworld" default="init" basedir=".">
<property file="./build.properties"/>
<target name="init">
<mkdir dir="${dir.project.build.phing.tmp}"/>
</target>
<target name="clean">
<delete dir="${dir.project.build.phing.tmp}"/>
<phingcall inheritRefs="true" target="config-delete">
</phingcall>
</target>
<!---
============ php application config.json ==================
-->
<target name="config-delete">
<delete file="${php.application.config.json}"/>
</target>
<target name="config-create">
<mkdir dir="${dir.project.build.phing.tmp}"/>
<copy file="${php.application.config.ini}" tofile="${php.application.config.parsed.ini}" overwrite="true">
<filterchain>
<replacetokens begintoken="{{" endtoken="}}">
<token key="projectName" value="${project.name}" />
<token key="environmentName" value="${project.environment.name}" />
<token key="hostDefault" value="${project.host.default}" />
</replacetokens>
</filterchain>
</copy>
<exec
command="${cmd.ini2json} -s ${php.application.config.parsed.ini} -t ${php.application.config.json}"
passthru="true"
/>
</target>
<!---
============ composer ==================
-->
<target name="composer-download">
<exec
command="curl -sS ${url.composer.download} | php -- --install-dir=${dir.composer.bin}"
passthru="true"
/>
<exec
command="chmod +x ${dir.composer.bin}/${cmd.composer}"
passthru="true"
/>
<phingcall inheritRefs="true" target="composer-self-update">
</phingcall>
</target>
<target name="composer-self-update">
<exec
command="${cmd.composer} self-update --working-dir ${dir.project}"
passthru="true"
/>
</target>
<target name="composer-optimize">
<exec
command="${cmd.composer} dump-autoload --optimize --working-dir ${dir.project}"
passthru="true"
/>
</target>
<target name="composer-install">
<phingcall inheritRefs="true" target="composer-self-update">
</phingcall>
<exec
command="${cmd.composer} install --working-dir ${dir.project}"
passthru="true"
/>
<phingcall inheritRefs="true" target="composer-optimize">
</phingcall>
</target>
<target name="composer-update">
<phingcall inheritRefs="true" target="composer-self-update">
</phingcall>
<exec
command="${cmd.composer} update --working-dir ${dir.project}"
passthru="true"
/>
<phingcall inheritRefs="true" target="composer-self-update">
</phingcall>
<phingcall inheritRefs="true" target="composer-optimize">
</phingcall>
</target>
<!---
============ phpunit ==================
-->
<target name="phpunit-download">
<exec
command="wget ${url.phpunit.download}"
passthru="true"
/>
<exec
command="chmod +x phpunit.phar"
passthru="true"
/>
<exec
command="mv phpunit.phar ${dir.phpunit.bin}/${cmd.phpunit}"
passthru="true"
/>
</target>
<target name="phpunit-skelgen-download">
<exec
command="wget ${url.phpunit-skelgen.download}"
passthru="true"
/>
<exec
command="chmod +x phpunit-skelgen.phar"
passthru="true"
/>
<exec
command="mv phpunit-skelgen.phar ${dir.phpunit-skelgen.bin}/${cmd.phpunit-skelgen}"
passthru="true"
/>
</target>
<!---
============ vhost ==================
-->
<target name="vhost-create">
<exec
command="${cmd.vhost_create} ${project.name} ${project.host.default}"
passthru="true"
/>
</target>
</project>
projectName={{projectName}}
environment.name={{environmentName}}
host.default={{hostDefault}}
locale.default.lc_all='C'
locale.default.timezone='Europe/Berlin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment