In my Beyond Frameworks talk, I explained how a component-based architecture can help answer some of the important (i.e. expensive!) questions you might face when creating long-lived apps that rely on a PHP framework. In this series of blog posts, I’m going to look at how to go about creating and working with components.
I’ve just put out ComponentManager version 1.1.0, with the following (hopefully useful) changes:
Improvements To The php-library Skeleton
Bug Fixes For The php-library Skeleton
- Now tested on both Ubuntu and Fedora 14, especially for @phpcodemonkey.
- Now excludes .DS_Store folders from the final component, for those using these tools on OS X.
- Now excludes .svn folders from the final component.
- Now excludes .empty files from the final component.
How To Upgrade
To upgrade your installation, please do the following:
$ pear clear-cache
$ pear upgrade pear/pear
$ pear upgrade Gradwell/ComponentManager
Once the latest version of ComponentManager has been installed, you can upgrade the skeletons of your existing components by doing:
$ cd <where-I-put-it>/<my-component>
$ phix php-library:upgrade .
You will then want to edit build.properties, to set the new properties added in this release.
Any problems, let me know.
About The Author
Stuart has been writing PHP applications since 2003, and has been contributing to open-source software since 1994. He was an early writer for php|architect, a co-author of the Official Zend Certification Study Guide for PHP 4, and a regular speaker at conferences and user groups since 2004.
When he's not designing software, Stuart loves to explore the world through a camera lens, spend time with his beloved guitars, and continue his study to T'ai Chi Chu'an (Taijiquan).
Be the first to leave a comment »
In my Beyond Frameworks talk, I explained how a component-based architecture can help answer some of the important (i.e. expensive!) questions you might face when creating long-lived apps that rely on a PHP framework. In this series of blog posts, I’m going to look at how to go about creating and working with components.
In previous articles, I’ve introduced you to the component skeleton that phix creates for you when you run the phix php-library:init command. Our skeleton is designed to be extremely clean, so that it is very easy to automatically generate your PEAR-compatible component and its package.xml file, so that you don’t have to maintain it yourself (a process which would only end in tears).
At the heart of our skeleton, are the design constraints imposed by the PEAR installer, and that means the way it handles files differently depending on the file’s role.
What Are File Roles?
A file’s role is simply a way of telling the PEAR installer where you want the file installed. The PEAR installer supports the following file roles:
- data – any data files that your component needs to read at run-time
- doc – documentation about your component
- php – your PHP code
- script – any command-line scripts your component includes
- test – your (hopefully, PHPUnit-based) tests
- www – PHP code to be served by Apache
… plus a few more that are of no interest to authors of PHP components.
Where Do I Put Files For Each Role?
To make it extremely easy for the phing pear-package command to auto-generate your package.xml file, there’s a folder in our component skeleton for each type of file.
Here’s a handy summary showing you where to put your files inside your component, based on their role:
- data – goes in the src/data/ folder
- doc – goes in the src/doc/ folder
- php – goes in the src/php/ folder
- script – goes in the src/bin/ folder
- test – goes in the src/tests/unit-tests/ folder
- www – goes in the src/www/ folder
In the next few articles, I’m going to look at each of these file roles in turn, and show you in detail how the PEAR installer treats them, and how to work with them in your own components, starting with the php role.
About The Author
Stuart has been writing PHP applications since 2003, and has been contributing to open-source software since 1994. He was an early writer for php|architect, a co-author of the Official Zend Certification Study Guide for PHP 4, and a regular speaker at conferences and user groups since 2004.
When he's not designing software, Stuart loves to explore the world through a camera lens, spend time with his beloved guitars, and continue his study to T'ai Chi Chu'an (Taijiquan).
Be the first to leave a comment »