Planning Center Online

This morning I woke up very early, feeling pretty excited about really diving into doing development on the band site and the iPhone application for it.

I did some searching through the App store looking for drum related applications and got about a hundred hits. None of the existing applications do what I had planned, but it worries me that with so many drum related applications, a new drum application would get lost.

So I started searching for band lineup related applications, which is a bit difficult because I couldn’t think of any unique search keys. However, I finally located an iPhone application that referred me to their associated website www.PlanningCenterOnline.com.

OMG! This site has done just about everything that I had hoped to do with my band site, including an iPhone application and Facebook integration. This is a very sweet site, very well done. I am very excited about it, and looking forward to bring out own band up on it. I’m fighting off being disappointed that someone else beat me to the idea, and did it so well!

One of the really coincidental aspects of this site is that the creator of the site is a music minister at Central Christian Church in Henderson near Las Vegas. I had written the song “A Place in Sin City” shortly after visiting that church early last year. I’ve also recently been in touch with my ex-brother-in-law, and he has become very active at that church.

This whole thing has the appearance of having God’s hand all over it. Now I just need to figure out what He wants me to do with it. I’ll probably start by sending a letter over to PCO and see if they need any help.

Improving my Skills for a new line of work

In trying to discern where God is sending me, I’ve had the feeling that there are 2 strong possibilities:

  1. Utilize my web programming skills in order to extend our band site.
  2. Brush up my Cocoa skills and get involved in iPhone development.

I’ve been playing with our church’s band website for several years, and it occurs to me that this might be something that I could extend to allow other churches or music related organizations to use. I think that some of the key features are the ability to create lead sheets, reuse them in lineups, and transpose them. The ability to strip out the chords for use by singers is also very useful. I had originally implemented this as a WordPress plugin, but then converted it to a Zend Framework based custom application, eventually adding Dojo support. I’m thinking about moving it back into WordPress.

iPhone development has always appeared very appealing also. I’ve recently started refreshing my Mac Cocoa programming skills, and these are exactly the same skills needed for iPhone development. Earlier this week I had joined the iPhone development program. I have some ideas about a simple application to use with my drumming. My primary motivation for doing this though is to work on an iPhone application which would access the band site to display the current week’s lineup and allow playing the MP3s.

I plan on using my C# skills to create similar applications for the PC in addition to a Mac Cocoa application which would use the same web service for listing the current week’s lineup using a PC or a Mac.

Opportunity for a change

This morning they closed down the software development office here in Austin where I was working. We’ve been expecting this to happen, so this didn’t really come as much of a surprise. I’ve been feeling for awhile now that God has had some other things in store for me, although I don’t know what yet.

The severance package is pretty good, so I’ll have some time to figure out what God wants me to do, perhaps learn some new skills, or brush up some old skills.

I have a vague feeling that God wants me to do something different than the big enterprise software development that I’ve been doing for most of my life.

I’m feeling pretty good about the change. I just wish I knew where God is sending me 🙂

My only fear at this point is that I might not discern correctly God’s direction for me, and/or that I’ll end up squandering this time off instead of using it to prepare for God next thing for me.

Cocoa Programming

I’m starting back on my Cocoa programming. I plan on writing iPhone applications and maybe some Logic plugins. To get started though I’m going to go back through the Aaron Hillegass book before diving into the iPhone SDK. It’s been awhile since I read this before, so I’m going to need the refresher. So starting today at chapter 1.

In chapter 2 I create a new project. I’m using the 3rd edition book copyright 2008 but it’s already a bit outdated since XCode now has iPhone stuff in it.

Reorganize Subversion Repository

I’ve restructured the repository to use the standard layout:
/oldsite
/oldsite/trunk
/oldsite/branches
/oldsite/tags
/newsite
/newsite/trunk
/newsite/branches
/newsite/tags

I’ve put all the existing code into /oldsite/trunk and created a new Zend Framework project in /newsite/trunk.

This is evidently confusing Zend Studio 7, because now it won’t add a new project to the repository. I’ve tried cleaning things up, retrying, etc. but I still end up with red exclamation marks next to all the files, and nothing has been added to the repository.

Doing some google searching, it appears that a lot of folks are having problems with the SVN support in ZS. Several mention that due to these and other bugs in ZS they have opted to use Aptana instead. Since Aptana is free, I’m going to give it a try and see how hard it is to setup my project and SVN connection.

Common ZendServer and Zend Studio Directory

One of the problems that I’ve been having with using Zend Server CE and Zend Studio 7 is understanding and managing where the files are located.

Since I’m developing on Mac, I naturally started with trying to use the ‘Sites’ directory. This meant that I had to switch the ZS7 workspace, which for some reason is a bit flakey. I would then need to reroute Apache’s documentroot or better create a vhost to point to the project in Sites.

It appears that ZS7 can automatically detect ZSCE and will create projects in its documentroot directly if ‘Create project on a local server’ is selected during the project creation process. This results in the new project appearing in the ZSCE documentroot directory, by default /usr/local/zend/apache2/htdocs.

It will probably be a lot less confusing to leave the ZS7 workspace and ZSCE documentroot in their default location and simply create a link in ~ (‘ln /usr/local/zend/apache2/htdocs DocumentRoot’) to the ZSCE documentroot folder instead of using the Sites directory.

Another confusing thing is the relationship between the Workspace, ZS Projects, and actual file locations. The Workspace is where ZS will create Project folders. Projects can reference files located elsewhere as implied by the above note. So files can be located in the Apache documentroot (wherever that is) and projects created in a separate Workspace. They don’t have to, and probably shouldn’t be the same location.

Debugging the Debugging Environment

It can be pretty frustrating to sit down to do some web coding, only to find that the development IDE or server isn’t working correctly. One then spends the time planned for development on simply debugging the development environment instead.

This often happens to me due to the following things:

1. I’ve deleted a project’s folder without removing the vhosts reference to it. This will cause the Apache server to fail to start.

2. I’ve made changes to the httpd.conf or httpd-vhost.conf file without restarting Apache right away to confirm that the settings work correctly.

The easiest way to debug this is to look in the Apache log files. Apache can also be manually started using apache2/bin/httpd and may generate messages.

1. Try to launch the ZendServer control panel. Sometimes this fails if the system is still starting up, so wait until boot up is complete.

2. Check the Apache error_log.

3. Try manually starting using apache2/bin/httpd.

Trouble with debugging

I apparently have screwed up my Zend Studio 7 debug settings. I can launch the debugger ok from within Zend Studio 7, but any breakpoints that I’ve set on subsequent pages don’t ever trigger. I can also see the browser output indicating that the code all ran.

At this point I’m getting so frustrated that I think I’m going to start with a fresh install of Zend Studio 7, ensure the debug example works, recreate my project, and see if all works then.

Everything is backed up on Time Machine, so here we go.

Installing Zend Server CE

Zend Server CE is a package containing Apache, PHP, MySQL, and the Zend Debugger. It is a great way to quickly install the full environment needed for PHP development. It is also free.

Installation is pretty simple, mostly download and run.

After installing, you’ll probably want to setup multiple virtual hosts. This requires editing two Zend Server files (conf/httpd.conf and conf/extra/httpd-vhosts.conf) and /private/etc/hosts.

The ZendServer control panel is accessed through the default localhost documentroot folder, so its probably best to leave localhost where it is. Alternatively it may work to copy the ZendServer link that is in /usr/local/zend/apache2/htdocs to whereever localhost gets moved to.

Create new vhosts by uncommenting the vhosts file include in httpd.conf. Then create as many vhost sections as needed. Be careful that any specified log files are within folders with permissions enabled. Also be sure to copy the localhost permissions section in httpd.conf for the location of the vhosts folders (eg. Sites). Remember to setup localhost or the Zend Server control panel will be broken.

MySQL Backup/Restore

I’ve been working with MySQL databases years. Since most of my projects have been fairly small, I’ve managed backups and schema updates manually using phpMyAdmin. Typically I will setup 3 separate server environments and databases: dev, test, and live.

User Scenarios

The scenarios that I would like to implement are:

  1. Create ‘dev’ database, tables, and optionally initial content.
  2. Optionally import existing content from ‘live’ to ‘dev’.
  3. Develop and test code using the ‘dev’ environment and database.
  4. Copy the ‘dev’ database to the ‘test’ database
  5. Optionally import existing content from ‘live’ to ‘test’
  6. Test using the ‘test’ environment
  7. Lock the ‘live’ database
  8. Backup the ‘live’ database
  9. Copy the ‘test’ database to the ‘live’ database
  10. Restore the ‘live’ content
  11. Unlock the ‘live’ database

MySQL supports doing all of these things.

Creating the Database and (optionally) Initial Content

Creating the database is done using CREATE TABLE. Using a PHP function to do this works well because then the structure of the table is documented and can be checked into the SCM.

Importing Existing Content

Development on the ‘dev’ site is easier if the ‘dev’ database contains valid data. If the ‘live’ and ‘dev’ databases reside on the same server then the content from the ‘live’ database can easily be copied into the ‘dev’ database using ‘INSERT INTO dbname.tablename (cols) SELECT cols FROM dbname.tablename’. If not, then the ‘live’ database will need to be unloaded to a file, then the file loaded into the ‘dev’ database as described for backup below.

Copying the Dev Database to Test

Once new code is developed and tested in the ‘dev’ environment it needs to be copied as-is to the ‘test’ environment. This is easily done using ‘CREATE TABLE dbname.tablename AS (SELECT * FROM dbname.tablename)’. Updated content can be copied from ‘live’ to ‘test’ as described above for copying data into ‘dev’.

Lock the Live Database

Although MySQL provides a locking mechanism, this is probably not the best approach in this case. A better approach might be to set a flag in the user login or identification code. I call this setting a ‘service mode’. Other users that try to interact with the site will be told that the site is down for service, and to try again later.

Backup the Live Database Content

MySQL provides a BACKUP and RESTORE commands, but these are marked as ‘deprecated’. Since the structure of the database is recorded in the code which creates the database, only the content needs to be backed up. This can be done using what MySQL calls ‘unloading’ and ‘loading’: “SELECT * FROM table INTO OUTFILE filename FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”‘ ” and “LOAD DATA INFILE ‘filename’ INTO TABLE table FIELDS TERMINATED BY ‘,'”

Recreate the Live Database

Use the same code that was used to create the ‘dev’ tables to recreate the ‘live’ tables.

Restore the Live Database Content

As stated above, MySQL provides a RESTORE command but it is marked as ‘deprecated’. Since the structure of the database was recreated in the previous step, load the content using “LOAD DATA INFILE ‘filename’ INTO TABLE table FIELDS TERMINATED BY ‘,'”

Unlock the Live Database

This is done by turning off ‘service mode’.