October 2009 Archives

Today I posted my update to ctshryock/MGTwitterEngine which allows you to use the API's update_profile_image and update_profile_background_image. I added to the demo app a window that lets you select an image for either profile image or background image to see it in action.

I had to modify some of the internals to get this to work... originally the _sendRequestWithMethod:path:queryParameters:body:requestType:responseType: method built the NSMutableRequest object internally, but to minimize code duplication I split the initial creation of the request into a new method _baseRequestWithMethod:path:queryParameters: to do that, and added a new method _sendDataRequestWithMethod:path:queryParameters:filePath:body:requestType:responseType: . Both _sendRequest... and _sendDataRequest... call _baseRequest... to start, with the latter adding the needed form/multipart data to the request.

Handcrafted

A comrade of mine has made a very nice custom Textmate theme. If you're using Textmate (which I use and love) you can check it out here: TextMate theme - Handcrafted

Using Zend Tool

Zend Tool is a powerful command-line script to help generate Zend Framework "units" as I call them, from the complete initial application structure to controllers, or actions in controllers that already exist.

Though released a the incubator a few versions back, I've found it to be more stable and easier to setup just recently. Fortunately I just did a clean install and lost my setup of Zend Tool, giving me the chance to blog about it here.

I first learned how to setup Zend Tool with this guide. It details at least two ways to get Zend Tool running, plus some instructions for Windows users. My instructions will be for Mac OS X (but should work for most Unix-like systems) and for development purposes only.

Getting Zend Framework

First step is getting the framework. Zend Tool requires the Zend Framework be in your php.ini's include_path, so you need to obtain the source. The Zend Framework source is available for public checkout via subversion, and since you're developer, we'll go that route. Personally, I like to checkout a release tag and not a trunk, that way I can incrementally update from tag to tag instead of just updating from the trunk. Either should work. I use my user's Sites folder for all my development work so I'm going to check it out there.

svn co http://framework.zend.com/svn/framework/standard/tags/release-1.9.4 ZendFramework

It's not small, depending on your network, this could take awhile...

Once that's finished, lets take a look at what we've got.

cd ZendFramework
open .

You should see something like this: ZendFramework.jpg

The core library is in library/Zend, and the Zend Tool scripts are in bin/.

Add Zend Framework to your Include Path

Second step is to add the the contents of the Zend folder to you include path. I'm using Macports so php.ini file is located in /opt/local/etc/php5/. By default the includes path was commented out and looked like this: ;include_path = ".:/php/includes"

Change that to uncomment it and add the library folder of your checkout

include_path = ".:/php/includes:/Users/clint/Sites/ZendFramework/library"

Setting up the script

The bin folder comes with 3 scripts, a shell script zf.sh, bat script for Windows users zf.bat, and a php script that they both use zf.php. zf.sh is the script I'll be using and we need it on our system PATH, which I'm going to do via symbolic link

sudo ln -s ~/Sites/ZendFramework/bin/zf.sh /usr/bin/zf

Using Zend Tool

Check to see if Zend Tool is working by typing zf into the command-line:

output.jpg

The first thing you'll see is an error, since we didn't supply the correct number of arguments, but following that you'll get usage instructions for all the options of Zend Tool.

Now lets create a project by switching to your local server's document root and running :

zf create project test-app

Now take a look around at what was made by opening test-app

test-app-structure.jpg

and view it on the web: http://localhost/test-app/public. You should get the default homepage setup of a Zend Framework Application:

home.jpg

Zend Tool can do more than just create the project structure, so lets create a controller and an additional action.

cd test-app
zf create controller tool

You can see that Zend Tool created a controller named ToolController and added view scripts for you under views/scripts/tool/

tool-controller.jpg

You can see the default text for that script here: http://localhost/test-app/public/tool

Now lets create an action. Zend Tool's create action method takes requires a controller name as the second arguement; if you don't specify one, it will assume you want to use the Index Controller.

zf create action example tool

Your results should be like this:

tool-example-action.jpg

There are other options and methods in Zend Tool; if you've made this far and understand, you can figure them out

EMKeychain update

I originally found EMKeychain a few months back and added it to my project to take over managing interactions between my app and the Keychain. It worked well until I updated to Snow Leopard and started using the LLVM GCC 4.2 compiler. Doing so threw some new errors about non-explicit casts and deprecated methods. I went in search of an update on Extendmac's site and by chance found @sdegutis's fork of the project on GitHub.

I forked the project here and started replacing my current EMKeychain setup with this new one. The newer isn't terribly different but it went from 4 files to 2, and we're not using "proxy" object anymore instead just class methods for getting / creating keychain items.

One thing I did notice is the inconsistent results, but I don't think it's due to this newer version. I created a temp project and ran a loop getting and printing a specific keychain password 10 times and got the actual password, null, or the password with some extra characters at random times. Not encouraging.

Luckily I did track down the issue; the raw char password wasn't being converted to an NSString object correctly, so I was able to write a patch using the C strncpy method. You can check out my *fixed* version with the link above, but I did find in the network what is probably a better fix with user irons fork, which I plan on integrating soon.

Stackoverflow

About this Archive

This page is an archive of entries from October 2009 listed from newest to oldest.

August 2009 is the previous archive.

November 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.