Added by Kevin Vaughan, last edited by Kevin Vaughan on Jul 15, 2007

Labels

 

Kevin Vaughan

Kevin Vaughan - Zend Framework
(Random thoughts on random things...)
BaseApp 1.0.0a5 - Minor update: Deployable to providers!
Tonight marks a minor update to BaseApp, 1.0.0a5. Many users of BaseApp have requested direct support for deploying the archive into a hosting provider where they are not able to have some of the files out of the web space. While the security of this is not as good as having everything except the html directory outside of the document root, it is a common occurrence and not addressing this situation could be more hazardous for some users without proper guidance. This update provides an index.php in the root directory, and .htaccess files in subdirectories to restrict direct code access or access to other files. It is recommended that you delete the html directory if you plan on deploying in this manner, and to read the comments in the index.php bootstrap to better understand this deployment.


Download this update to BaseApp, v1.0.0a5, and get started today!
Inside BaseApp, Part 1 - Zend Framework and the Bootstrap
This entry is about the use of Zend Framework and BaseApp, an application layer built on top of the framework libraries.

One of the things I noticed as I was getting started with the Zend Framework libraries was the smell coming from all of the bootstrap files... a lot of setting of variables, adding directories to this or that, creating various objects for random tasks, and a growing urge to do more and more setup in this bootstrap. This is BAD practice for a few reasons, but here are the two big ones for me:
  • Maintainability - did we not learn from php4? Non-OOP code just gets worse and worse over time. It gets unorganized, it gets unfocused, and soon the bootstrap, just like the index.php scripts of old, begin to do too much for their role.
  • Reuse - which sounds like a better idea: copying the code over and modifying the section that you want to act differently? or extending a class and only writing new code where its applicable? If you found yourself nodding in approval to the first option, buy this book for good insight into why the second option will make your life much easier.

BaseApp minimizes the bootstrap to a very simple form: set the application path, instantiate the main application class, call any special configuration methods of that object, then execute the main method of the application object. In the included example index.php, this is 5 lines of code. The application object, BaseApp_Loader, handles all of the specific setup that you otherwise see in bootstrap files.

So what about BaseApp_Loader? What does it do? Why is it better than a typical bootstrap?
  • XML Configuration - Uses Zend_Config_Xml to load an application level configuration file. Now if you want to launch a second copy of a site, for example, you can use the same exact code libraries and point at different configuration file to use different databases, etc. By using an xml configuration and capturing exceptions through the main application setup process, simple errors like typos won't bring your site crashing to 500 Internal Server Error.
  • Method Based Configuration - Each type of configuration is split off into its own method within BaseApp_Loader, so if you want to setup logging to do something other than Zend_Log, or configure database usage differently than the default Zend_DB implementation, you can override the individual method in an extension of the BaseApp_Loader class. Each of these methods receives a Zend_Config object rather than referencing the application's config directly, allowing for easy overrides by subclasses while minimizing the impact of the underlying structure.
  • Zend_View Choices - Included in the default implementation are Zend_View and BaseApp_View_Smarty (a Smarty based view). BaseApp allows you to decide what view you want to use in a way that is flexible, and you can add your own if you want (by following BaseApp_View_Smarty as an example, if you need).
  • Easy Registration - For modules, views, log control, database control, helpers and more. Utilizing these powerful constructs provided by the Zend Framework libraries is extremely easy using the BaseApp_Loader's methods or overriding them with your own.
BaseApp 1.0.0a4 - Admin abstraction, Auth integration
Thanks for everyone's patience last week. Some other projects took precedence and I couldn't get as much time into BaseApp as I would have liked. There were some good comments on the last release though, and I'm seeing some good download numbers. I've taken some of those comments and integrated them in; other's didn't make as much sense to carry over into the main source, but thats why this is BaseApp. It thrills me to see people taking it and using it as a quick start for their own application, modifying it to fit their needs. This week has a couple of main additions:
  • In previous versions, the authentication functions were commented out as I struggled to decide on what ORM to integrate. I really like propel, but I don't want users of BaseApp to have to have command line access. There are a couple of other up-and-comers, and hopefully they'll get to a stable release point soon. In the meantime, I've implemented auth using the Zend_DB libraries, so at least you can see a sample simple integration of those for adding users.
  • Speaking of the auth module, I've also used the user login form to show examples of the power of the Xend_Layout request.
  • Finally, I've started an administration abstraction. The main controller for this is AdminController in the default module, and each module reports its own admin functionality. No ACL is in place for any of this yet.

Next version:
  • ACL integration into the administrative functionality.
  • Example administrative controls using the auth module to add/edit/delete users.

Additionally, check back often for an "Inside BaseApp" series of posts that will be aimed at describing everything from setting up BaseApp to why particular object structures were chosen.

Thanks again to everyone for their continued support. You can grab the latest version from BaseApp Downloads.
BaseApp update: 1.0.0a3 - phpdoc, Xend_Layout, complex error handling
This week's update to BaseApp includes:

  • Inclusion of phpdoc into all BaseApp classes

  • Integration of Xend_Layout with example layout usage

  • Implementation of complex error handling, allowing for easy module specific error controller usage

  • Minor modifications to smarty inclusion to allow for easier usage


As always, you can download from the BaseApp downloads page, or pull down the latest version directly. The next integration will be an ORM layer and an administration abstraction.
BaseApp update: 1.0.0a2
Minor update today for BaseApp. Updates include:

  • Changed Smarty integration to extend Zend_View_Abstract instead of implement the base interface

  • Removed the free-form class autoloader and replaced it with basic Zend_Loader to promote better coding standards and portability

  • Various small tweaks to move towards being in line with ZF coding standards (phpdoc to come soon!).

  • Updates to the BaseApp information pages



You can always get the latest version of BaseApp from the BaseApp downloads page, or pull down the latest version directly.

Thanks to Naneau, SpotSec and other visitors of #zftalk on irc.freenode.net for the continual ZF conversation!
BaseApp - An application core layer built on Zend Framework
After spending some time playing with the recently released Zend Framework, I decided to build a core layer to sit on top of the framework to make it easy to be able to quickly jump into development. Once I started, I also saw a lot of people on various ZF related forums and in #zftalk on irc.freenode.net asking for examples of various integrations and implementations using the framework.

Unfortunately for the community, most of the examples that are readily available use older versions of the framework and are no longer functional or don't utilize some of the newer functionality properly.

So, I've put up an early copy of BaseApp - an application core layer built the Zend Framework (direct download). Features in this alpha version include: a modularized component structure; main application controls, logging and configuration; graceful Smarty template integration; basic content structures controls with search engine friendly URLs; and class autoloading and easy deployment capability.
Zend Framework v1.0.0 and SEO Links
First off, if you haven't checked out Zend Framework, the first official release came out earlier this week. It takes a little bit to get around and learn the structure if you haven't seen it before, and probably a little bit longer still if you aren't familiar with things like design patterns, but this is the first really solid effort towards a framework for PHP 5.

Now, you've spent some time reading through the framework site, the documentation, whatever, and you're ready to get started. But the default link structure is not very search engine friendly and you want to dig into some different routing. What to do? Try out this content path router route, based on the other routes provided within the Zend Framework. This router will match all URL structures that end in either the Uri delimiter (/) or the content extension (default .html) (( but not /.html, )). The page and path will be set as request parameters so that your controller can determine if that particular page is supposed to exist based on whatever logic or business rules you decide.