About Chris Morrell

I am a Philadelphia web designer and developer who focuses on PHP development and usable design. I am also the Director of IT for the International Association of Certified Home Inspectors.

Please Note: My site fell victim to a Wordpress security flaw a few weeks ago, and I'm just getting everything back to normal. Please bear with me.

I am currently not accepting any new clients.

Other Sites/Clients

Contact Me

If you need to get in touch with me, my name is Chris and my domain name is cmorrell.com. Think about it.

Zend Framework Bash Completion Script

Posted by Chris Morrell on March 20th, 2010 in Zend Framework

If you use the Zend Framework CLI interface much you probably find yourself expecting tab-completion to work.  Well, with this bash completion script it will.  Just add the following line to your .bashrc or .bash_profile:

source path/to/zf.bash

Next time you load the terminal, you can type “zf c” and hit TAB twice to see a list of available commands (change, configure and create” or type “zf cr” and hit TAB to have “create” automatically inserted for you.  The script works for both action names and provider names (but not for anything past that).  Eventually I want the script to dynamically load the available commands (so that it works with custom providers and future versions of ZF without updates) but I couldn’t get that working for this version so I just hard coded them.

There’s also a version that completes commands from the Galahad Framework Extension if you’re testing that out…

Zend Framework CLI Bash Completion Script [1.71 KB]

Enjoy!

4 Comments »

Namespacing ACL resources & Galahad_Acl

Posted by Chris Morrell on March 17th, 2010 in Zend Framework (tagged )

In most of my applications I like to handle authorization (querying the ACL) in one (or more) of three ways:

  • Authorize access to a model’s method
  • Authorize access to a controller action
  • Authorize access to an arbitrary “permission”

In general I find it’s best to keep authorization within the domain (querying the ACL within my models when they’re accessed) as this provides the most consistent behavior.  For example, if I eventually add a REST API to my application I don’t have to duplicate all my authorization logic in the new REST controllers.  When the application calls something like Default_Model_Post::save() it either saves or throws an ACL exception, no matter where it was called from.  This is great in that it saves me from having to duplicate code and keeps my system more secure.

On the other hand, there are times when it’s just a lot easier to handle authorization in the controller.  For example, if guests should never access my “Admin” module, it doesn’t make sense to ever let them access /admin/ URLs.  Also, if you’re using Zend_Navigation, having ACL resources that match controller actions lets you utilize its ACL integration.

If you’re ever going to mix these two techniques, you’ll eventually bump into the case where a model and a controller share the same name.  What if you need to set permissions on a “user” controller and different permissions on a “user” model?  This is where namespacing comes into play.  As suggested by the Zend Framework manual, I always name my controller action resources in the format mvc:module.controller.action.  I name my model resources similarly, in the format model:module.modelName.methodName.  In both theses cases, “mvc” and “model” are the namespace, and everything following the colon is the actual resource name.  Now I can refer to my “admin” module as mvc:admin and the models within my admin module as model:admin.

This is where things get interesting.  If you set up your ACL chains correctly, you can set permissions on whole modules or models and have those rules cascade to their child controllers or methods.  For example, say you set up your ACL as follows:

$acl = new Zend_Acl();
$acl->addResource('mvc:');
$acl->addResource('mvc:admin', 'mvc:');
$acl->addResource('mvc:admin.user', 'mvc:admin');
$acl->addResource('mvc:admin.user.create', 'mvc:admin.user');

$acl->addRole('guest');
$acl->addRole('admin', 'guest');

$acl->deny();
$acl->allow('admin', 'mvc:admin');

Now if a user with the role “admin” tries to access the resource “mvc:admin.user.create” (http://basename/admin/user/create) they will be allowed, but a user with the role “guest” will not.  Using this technique gives you as much granularity as you need in your ACL, but at the same time lets you set broad permissions where appropriate.

This is where Galahad_Acl comes into play.  Setting up all these resources can be tedious, as is checking permissions in each controller.  Galahad_Acl in conjunction with Galahad_Model_Entity and Galahad_Controller_Plugin_Acl automate everything but the actual permissions that are specific to your application.

Continue reading “Namespacing ACL resources & Galahad_Acl” »

No Comments (Respond Now) »

Zend Framework URI validator & filter

Posted by Chris Morrell on March 12th, 2010 in Zend Framework

For the last couple of months I’ve been incorporating portions of applications I’m working on into my Galahad Framework Extension project.  Right now it’s not at a point where I’d feel comfortable promoting it (you can check out the project on GitHub if you want), but there are portions that are pretty solid that might be useful to others right now.  Two such portions are Galahad_Validate_Uri and Galahad_Filter_PrependHttp which are both very useful for processing forms with URL fields.

Continue reading “Zend Framework URI validator & filter” »

2 Comments »

My response to livestream

Posted by Chris Morrell on March 3rd, 2010 in Video (tagged )

Today livestream announced a new “zero tolerance on piracy” program.  The following is my response to their promotional email marketing this “feature.”
Continue reading “My response to livestream” »

3 Comments »

Soup phase 3 (eating!) http:/…

Posted by Chris Morrell on February 25th, 2010 in twitter (tagged )

Soup phase 3 (eating!) http://flic.kr/p/7FL3hR

1 Comment »

Sweet. Just saved about 60k a…

Posted by Chris Morrell on February 25th, 2010 in twitter (tagged )

Sweet. Just saved about 60k and 8 requests by installing PHP Speedy. That plus WP-Super-Cache is a killer combo. http://bit.ly/bi719l

1 Comment »

Stock: phase 2 http://flic.kr/…

Posted by Chris Morrell on February 25th, 2010 in twitter (tagged )

Stock: phase 2 http://flic.kr/p/7FFSni

1 Comment »

Chicken stock making preparati…

Posted by Chris Morrell on February 25th, 2010 in twitter (tagged )

Chicken stock making preparations. http://flic.kr/p/7FFwNc

1 Comment »

Mobile App Development slides …

Posted by Chris Morrell on February 25th, 2010 in twitter (tagged )

Mobile App Development slides from @panma event will be online as soon as my DNS changes propagate. Will post a link tomorrow some time.

1 Comment »

Mobile App Development for Web Developers

Posted by Chris Morrell on February 25th, 2010 in Misc

On February 23rd I gave a talk at PANMA’s Mobile App Development Demystified event. My talk was titled Mobile App Development from a Web Developer’s Perspective. Here are my slides:

Continue reading “Mobile App Development for Web Developers” »

1 Comment »

@inxilpro

  • Anyone want a free TiVo Series 2 w/ upgrade eligibility and month-to-month service? Its yours if I know you. 19 hrs ago
  • Just canceled the cable. 19 hrs ago
  • You know it's spring when the daily Tony Danza sightings start again. 21 hrs ago
  • More updates...
Copyright © Chris Morrell, Powered by WordPress, Entry RSS Feed / Comment RSS Feed