Take the 2-minute tour ×

I am writing a piece of small software to go through the folders and files of all the php projects that are passed in and detect if any of them is actually also a Zend project. Is there any particular file that I can immediately read and tell that the current project is a Zend project? or is there any convenient way to tell?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

alt text

This is the default directory structure that ZF creates for you when you start a project. So if you're just looking at directory structure this should work.

Alternatively you could look to see if a directory has a hidden file called .zfproject.xml.

I hope that helps!

share|improve this answer
Thanks Thomas. Can you tell me where .zfproject.xml locates exactly? Thanks again. –  Winston Chen Mar 30 '10 at 3:48
Again, is ".zfproject.xml" a must in any zend framework? –  Winston Chen Mar 30 '10 at 9:00
.zfproject.xml is located in the root directory of the project. So, in the above example it would be on the same level as the application, docs, and library directories. That file is automatically created whenever one uses ZF's tool to create a project. I guess it's possible to use ZF without using the tool, but I've never seen it done. Also, the library directory will usually contain a directory called 'Zend'. I would say that with these two criteria you will catch 99% of the Zend projects out there. There's always a chance, however, that somebody will be using a custom setup and... good luck –  Thomas Mar 30 '10 at 11:49
Thanks again, Thomas. You have done such a great help ;) –  Winston Chen Mar 30 '10 at 13:53
@Winston Chen: .zfproject.xml is not required by the Zend Framework, it just tells you that the person creating the project used Zend_Tool to create it. You could just as well create it without using Zend_Tool, and a lot of older (read : those that predate Zend Framework 1.8) projects will not have been created by Zend_Tool (since it didn't exist back then). –  wimvds Feb 24 '11 at 16:06
show 1 more comment

I don't think the above answer heads in the right direction. To begin,


Source: Zend Framework & MVC Introduction

Assuming that standard use will include both the suggested MVC structure and zftool for project creation is a bad assumption because many projects hand-pick a subset of Zend components to minimize the now 45MB class footprint.

Instead, lets look at a point Thomas hinted at in his answer above:


And now from Zend's Programmer's Reference Guide:

Zend Framework standardizes on a class naming convention whereby the names of the classes directly map to the directories in which they are stored. The root level directory ... is the "Zend/" directory ... All Zend Framework classes are stored hierarchically under these root directories..

Class names may only contain alphanumeric characters. Numbers are permitted in class names but are discouraged in most cases. Underscores are only permitted in place of the path separator; the filename "Zend/Db/Table.php" must map to the class name "Zend_Db_Table".

Important: Code that must be deployed alongside Zend Framework libraries but is not part of the standard or extras libraries (e.g. application code or libraries that are not distributed by Zend) must never start with "Zend_" or "ZendX_".

Source: Naming Conventions

A better suggestion would be to check for the root directory '/Zend', however this excludes any projects where the developer has decided to forgo the above suggestions and has thrown Zend class files into some global library directory.

The best guess would be to recursively glob all the files in a project's directory looking for class names that match the suggested pseudo namespace (Zend_ ...).

share|improve this answer
@Yenta thank you for your detailed explanation. It's really a very good answer. –  Winston Chen Mar 31 '10 at 3:22
add comment

Your Answer


