Question

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?

Was it helpful?

Solution

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!

OTHER TIPS

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

Zend Framework is often called a 'component library', because it has many loosely coupled components that you can use more or less independently.

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:

Also, the library directory will usually contain a directory called 'Zend'.

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_ ...).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow