Gold Apple Software Web Development by Geoff Appleby


CakePHP HasOne - BelongsTo Relationship Keys

The common pattern in CakePHP is to give each table a Primary, Auto Incrementing `id` column, but when utilizing HasOne and BelongsTo relationships between two models this column is superflous and can make tracing downstream relationships more difficult. For example, when splitting data between User and Profile models, giving the profile it's own `id` column adds no useful information since the `user_id` column will by definition be a unique reference to a user.  The auto increment values may remain in sync and give you two columns of duplicate data, but if they diverge models related to the profile (e.g. ProfilePhoto) now lose their direct association with the user model. It is relatively easy though to modify the models and clean things up.

A Simple Issue Tracker With Drupal

As I started working on more projects simultaneously, I found it a necessity to find a better way to track tasks. My best previous system was a wall full of colour-coded sticky notes, but I had difficulty translating it from keeping track of one organization's tasks to keeping track of all my freelance work.  I felt this site was the best place for me to keep track of things, with the potential to allow better interactivity with clients later, and so wanted to integrate something with Drupal.'s own project module (with Project issue tracking) is available, but as the description states, "Projects are generally assumed to represent software that has source code, releases, and so on." While the projects I work on generally have source code, they are not nicely packaged releases, and I can't use the issue tracking without the projects.  There are other Drupal modules available to support issue tracking, but I found they were all pretty complex and customized.  I figured Views and CCK would provide most of the features I would need on top of core Drupal, and so set out to construct a simple issue tracker.

Pushing to multiple repositories with EGit

One handy feature that I recently discovered in newer versions of EGit is the ability to push to multiple remote repositories at once. 

Previously for a Drupal module I would set up two remotes, origin (pointing to the sandbox repository) and github.  To push local commits to both then always required going through the push dialog twice; selecting the remote to push to, confirming the branches to push, and then finally initiating the transfer.

Now, by specifying multiple push targets in your origin configuration, you can now simply use Push to Upstream, either from the repository viewer or the project's team menu, and have your commits sent to both remote repositories simultaneously without requiring any extra dialogs.  Once complete, the status dialog will now include a column to dispay the result of pushing to each repository.

Organizing Eclipse Projects with Working Sets

My first use of Eclipse was in university, where to keep organized I would separate each course into its own workspace.  This was bred out of the fact the each course could typically have several labs and a term project, each with starter code from the professor in its own pre-made Eclipse project.  It was simply easier to have separate workspaces, each with their own "Lab 1" project than to sort through every project in a single workspace.  This presented its own challenges, however, as each workspace would have to be configured correctly and on occasion it would be necessary to review code between courses

Eclipse has remained my prefered IDE for PHP development.  A similar organizational issue has arisen as each client has their own project(s), and particularly with Drupal many contributed modules are involved as well.  It's simply not feasible to have separate workspaces for each client, especially when they utilize so much common code.  This is also compounded if you are working with multiple versions of Drupal or contributed modules through CVS (or learning about Git).

Using Eclipse and EGit for Drupal Development

Drupal will be migrating from CVS to Git (hopefully) soon, so there are benefits to introducing Git to your current workflow.  While CVS remains the primary code repository for Drupal projects, a Git mirror has been set up for some time and can be used now.  EGit is a team plugin for Eclipse that enables you to manage Git repositories from within Eclipse, utilizing a Java port of Git so that it is entirely self-contained.  Though it is under active development, it looks to have made some big strides in a short period and is likely suitable for most users.

Syndicate content