The Zendframework is a huge collection of useful PHP-Scripts, which helps you to code less and create more.
The complete framework comes in an about 18 MB big compressed file.
Decompressed the Zendlibrary folder contains more than 2700 files in more than 480 subdirectories.
The folders are ordered in modules, where each module provides a specific code for a certain solution.
So far so good, the problem is, that almost every module or standalone file within the framework depends on another module or file. This means that if you want to use only a specific module (e.g. Rest) you have to find out the dependencies to the other modules by try-and-error or to install the whole framework.
Sometimes it isn’t possible or recommended to install the whole framework, if you are writing applications for particular shared hosting enviroments or plugins for other applications.
So I was looking for an easy solution with which I can use only one of these modules without installing the whole Zendframework. So I wrote a small comandline php script that copies a module and all its dependencies in to a user defined folder.
This allows me to use the power of the Zendframework without the need to install it all. Another advantage is, that the distibution file set of the application or plugin will become much smaller.
How does the script work?
- The script is a comandline script and needs three parameter:
- where to find the library files (modules) normaly they are installed under Zendframework/library
- The module (directory name) or file you want to useful
- The path where to copy the files
What does the script do?
- it scans each file in the module directory if a line contains the function “require_once ‘”. If the script found such a line, it extracts the module name and path from the require_once function.
- With this information the script looks up the modules needed.
- Then the script looks up all dependecies from each module found
- this goes until all dependecies where solved and copied to the directory you specified