Monthly Archives: February 2011

Zend Framework Tool – project already exists here

When using the Zend Framework tool to create directory structures and some basic classes, you might come across the message “An error has occurred. A project already exists here”. A quick Google search found a couple of other people reporting this issue but no solution.

The problem occurs because by default the project provider searches all parent directories for a .zfproject.xml project configuration file. In my case I’d created a testing project further up the directory tree and neglected to delete it – this was fooling the tool into thinking a project already existed.

…which makes sense – you wouldn’t normally have a project inside a project (although you can’t rule out that somebody wants to do this)

Two solutions:

either look for a ZF project file in your parent directories:

find /path/to/htdocs -name '.zfproject.xml'

or, modify the code to search only the current directory if you have a directory structure that the tool doesn’t like

diff --git a/Zend/Tool/Project/Provider/Project.php b/Zend/Tool/Project/Provider/Project.php
index c24af5e..d3d75ea 100644
--- a/Zend/Tool/Project/Provider/Project.php
+++ b/Zend/Tool/Project/Provider/Project.php
@@ -61,7 +61,7 @@ class Zend_Tool_Project_Provider_Project
             $path = str_replace('\\', '/', realpath($path));
-        $profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE, $path);
+        $profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE, $path, false);
         if ($profile !== false) {
             require_once 'Zend/Tool/Framework/Client/Exception.php';

ZF create project diff

The simplest way to apply this patch in Linux is to use the command:

patch Zend/Tool/Project/Provider/Project.php < createprojectfix.txt

Note: your mileage may vary – this was the cause of my particular issue, but it’s possible this happens for other reasons.