A collection of Phing Tasks for a ZF2 app.
Note: it will look for config/application.config.yml
instead of
config/application.config.php
on bootstrap. If you use PHP config files,
you'll have to change the code in each Task's main()
method.
{
"require": {
"heartsentwined/zf2-phing-task": "1.*"
}
}
Phing is not bundled with this package.
You can install it through Composer and use the CLI at vendor/bin/phing
:
{
"require": {
"phing/phing": "*"
}
}
or through PEAR and use the CLI at phing
:
$ pear channel-discover pear.phing.info
$ pear install [--alldeps] phing/phing
You must initialize an instance of your Zf2 application through ZfTask before using any of the remaining Tasks.
Bootstrap the ZF2 application using the file foo/bootstrap.php
. The bootstrap file must return an instance of Zend\Mvc\Application
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="zf" classname="ZfTask" />
<zf bootstrap="foo/bootstrap.php" />
</target>
</project>
foo/bootstrap.php
:
/* do some bootstrap */
$application = Zend\Mvc\Application::init(/* config array */);
return $application;
Generate entities for the EntityManager doctrine.entitymanager.orm_default
, base directory at foo/src
, with filter Foo\Entity
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="d-entity" classname="DoctrineEntityTask" />
<d-entity em="doctrine.entitymanager.orm_default" filter="Foo\Entity" output="foo/src" />
</target>
</project>
Generate repositories for the EntityManager doctrine.entitymanager.orm_default
, base directory at foo/src
, with filter Foo\Entity
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="d-repo" classname="DoctrineRepoTask" />
<d-repo em="doctrine.entitymanager.orm_default" filter="Foo\Entity" output="foo/src" />
</target>
</project>
Generate proxies for the EntityManager doctrine.entitymanager.orm_default
, at directory foo/cache/proxy
, with filter Foo\Entity
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="d-proxy" classname="DoctrineProxyTask" />
<d-proxy em="doctrine.entitymanager.orm_default" filter="Foo\Entity" output="foo/cache/proxy" />
</target>
</project>
Update database schema for the EntityManager doctrine.entitymanager.orm_default
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="d-update" classname="DoctrineUpdateTask" />
<d-update em="doctrine.entitymanager.orm_default" />
</target>
</project>
Drop all database tables from the connection of the EntityManager doctrine.entitymanager.orm_default
.
This Task differs from Doctrine CLI's behavior. It drops ALL tables, not just those found in the metadata mapping files.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="d-drop" classname="DoctrineDropTask" />
<d-drop em="doctrine.entitymanager.orm_default" />
</target>
</project>
Load the Twig template foo/bar
.
<project>
<target>
<includepath classpath="vendor/heartsentwined/zf2-phing-task/src/task" />
<taskdef name="twig" classname="TwigTask" />
<twig file="foo/bar" />
</target>
</project>