Using Doctrine 2 in Zend Framework 2

Zend Framework 2 is getting close to release, and among the changes are new ways to handle dependency injection, and new ways to work with third-party code as modules. Rob “Akrabat” Allen has updated his iconic Getting Started with Zend Framework tutorial for ZF2, and it’s a great place to start.

After working through that tutorial, the next thing I wanted to do was figure out how to get the Doctrine 2 ORM up and running.

This article shows how to set up and use Doctrine 2 in Zend Framework 2, by extending Rob’s Getting Started tutorial to use Doctrine instead of Zend_Db.

See the complete source code for this tutorial on Github.

Updated 20 September 2014: Brought up to date with current versions of the ZF tutorial and updated Doctrine composer package name.
Updated 18 June 2012: Added support for new Doctrine config file format.

Updated 2 June 2012: Added support for ZF2 beta 4 and the new composer-based installation methods.

Continue reading

Using Apache Ivy to manage directory dependencies in non-Java projects

The sweet hereafter, by Eddie Van 3000

Web development projects often rely on third-party libraries that don’t really belong in version control alongside the application source code. For example, a PHP web application might depend on Zend Framework, Doctrine 2, and jQuery. To support a fully automated build process, I want to be able to retrieve and install the right versions of these dependencies into my application code base automatically.

There are several package management tools out there that support this kind of thing, but most seem overly complex or overly restrictive. Enter Apache Ivy, a simple and flexible dependency manager that integrates with the Apache Ant build tool. Unlike the other dependency managers I found, Ivy makes it easy to run your own repository and choose your own directory layouts and file formats.

The one drawback is that Ivy is designed to work with individual Java JAR files: archives that are typically extracted in memory by Java at runtime. I want to work with dependencies that are directories of library code, already extracted from their archives. This article shows how to set up Ivy and Ant to work together to manage such directory dependencies.

Continue reading