We’re Hiring!

July 29th, 2009

Imaging walking through the warehouse to your desk and hearing the sounds of motorcycle engines roaring as the smell of racing fuel fills the air. Does this sound like a great way to start your morning? If so, we have a job for you.

The company I work for RidersDiscount.com is looking for a PHP Developer to help us build our next generation web presence. RidersDiscount.com is a successful, growing online retail company that is seeking candidates in the West Michigan area to fill a full-time on-site position. Below is a link to the official job posting.

PHP Developer Position at RidersDiscount.com

If you are interested feel free to respond to the craigslist job posting or you can email me your resume at aj at ridersdiscount dot com.

Storing Magento blocks in a subfolder

June 24th, 2009

While integrating Solr with Magento I decided to create a superclass for the facet blocks to extend since the majority of their functionality was rather similar. I started by creating a file named Facet.php with the class Company_Search_Block_Facet in app/local/Company/Search/Block that extended the Magento_Core_Block_Template class. I next created the subfolder app/local/Company/Search/Block/Facet to store all my facet blocks and a file named Size.php that extended Company_Search_Block_Facet. The tricky part was getting it to work properly. I attempting to add a facet blocks to the right column using the following code.

$this->getLayout()->createBlock(’search/facet/size’);

The problem was it loaded my superclass Company_Search_Block_Facet instead of my child class Company_Search_Block_Facet_Size. After digging through some of Magento’s source code I found the solution. You need to use an underscore instead of a forward slash to load blocks in subfolders.

$this->getLayout()->createBlock(’search/facet_size’);

Now I can easily store my blocks in a subfolder keeping my Block folder nice and tidy.

Multiple PHP Environments with MacPorts

March 25th, 2009

A while back on Twitter I mentioned how I love that I can use ports to switch between different PHP environments with the flick of a switch. Demian Turner responded asking for more info on the subject spawning the creation of this post. That was 3 months ago and before it could collect too much dust Karl Tiedt provided the insistence inspiration to get off my ass and finish it, as he put it.

When I started working at OpenX my need to switch between various PHP environments arose. As it was required that I test all my code on multiple version of PHP since we supported a wide range of PHP versions. Basically I had it setup so I could test my code on 3 version (5.0.x, 5.1.x, & 5.2.x) of PHP 5 and 3 versions of PHP 4. The solution had to allow me to quickly switch environments with as little human interaction as possible. This is where MacPorts and a little shell scripting magic came into play. The nice thing about ports is you can compile the same application with different configurations and switch between them on the fly.

This is by no means a complete tutorial it’s a quick and dirty get started guide on how you can switch between PHP 4 and PHP 5 as quickly as possible using Apache 2 as the backend. This setup can also be extended to switch between various backends. For example switching between apache + mod_php5 and lighttpd + php5-fcgi. I won’t go into detail but by the end of this guide you’ll be able to figure it out.

Let’s get started by installing Apache 2

sudo port install apache2

Now that Apache 2 is installed we can move on to getting PHP 4 and PHP 5 compiled. Run the command below to use ports to install PHP 4 as a module for Apache 2 and PostgreSQL 8.3 since it’s a dependancey. Ports automates the installation of software. It downloads, configures, compiles and then installs PHP 4 including adding the necessary configuration lines to your Apache configuration.

sudo port install php4 +apache2 +macosx +pcntl +pear +postgresql83 +sockets +sqlite +t1lib +tidy

After it’s installed we need to deactivate PHP 4 otherwise the PHP 5 installation will error out since you can not have both the PHP 4 and PHP 5 ports activated at the same time.

sudo port deactivate php4

Next, we’ll install PHP 5

port install php5 +apache2 +macosx +pcntl +pear +postgresql83 +sockets +sqlite +t1lib +tidy

Note that the PHP 5 port installation will not modify your Apache httpd.conf file and you must do it manually. Once you have both ports installed it’s rather simple to switch between the two by running the two commands below

port deactivate php4

port activate php5

MacPorts will swap out the necessary files for you. However you must manually swap out the php.ini and your Apache httpd.conf file. This was definitely not going to cut it as I needed to be as effortless as possible so I whipped up a little shell script to get the job done.

#!/bin/sh
case “$1″ in
‘php4′)
/opt/local/apache2/bin/apachectl stop
/opt/local/bin/port deactivate php5
/opt/local/bin/port activate php4
cp /opt/local/etc/php4.ini /opt/local/etc/php.ini
cp /opt/local/apache2/conf/httpd.php4.conf /opt/local/apache2/conf/httpd.conf
/opt/local/apache2/bin/apachectl start
;;
‘php5′)
/opt/local/apache2/bin/apachectl stop
/opt/local/bin/port deactivate php4
/opt/local/bin/port activate php5
cp /opt/local/etc/php5.ini /opt/local/etc/php.ini
cp /opt/local/apache2/conf/httpd.php5.conf /opt/local/apache2/conf/httpd.conf
/opt/local/apache2/bin/apachectl start
;;
esac

Save the above script as php-switch in /opt/local/bin and make it executable. Then copy /opt/local/etc/php.ini to /opt/local/etc/ as php4.ini and php5.ini. Also do this for Apache’s /opt/local/apache2/conf/httpd.conf file to /opt/local/apache2/conf naming them httpd.php4.conf and httpd.php5.conf. Execute the script with either ‘php4′ or ‘php5′ as the parameter. The script will then shuts down Apache, deactivates the opposite PHP module, enables the specified PHP module, copies the necessary config files and then starts Apache.

Next lets install another version of PHP 5 that has the MySQL drivers instead of PostgreSQL

sudo port install php5 +apache2 +macosx +mysql5 +pcntl +pear +sockets +sqlite +t1lib +tidy

When switching between two versions of the same app that are compiled with different configurations you must explicitedly express the variants. For example to activate the PHP 5.2.5 port with PostgreSQL driver you’d run the following command

sudo port activate php5@5.2.6_1+apache2+macosx+pcntl+pear+postgresql83+sockets+sqlite+t1lib+tidy

Don’t worry if you forget the variants because if you try to activate a port without being explicted MacPorts will remind you.

root# port activate php5
—> Activating php5
—> The following versions of php5 are currently installed:
—> php5 @5.2.6_1+apache2+macosx+pcntl+pear+postgresql83+sockets+sqlite+t1lib+tidy (active)
—> php5 @5.2.6_1+apache2+macosx+mysql5+pcntl+pear+sockets+sqlite+t1lib+tidy (active)Error: port activate failed: Registry error: Please specify the full version as recorded in the port registry.

This should be enough to get you up. One thing that I don’t cover here that needs to be mentioned is PHP modules usually need to be compiled against different versions of PHP. For example if you use XDebug to debug your applications you’ll need a module compiled agains both PHP 4 and PHP 5. Use all code at your own risk.

Get the Vote OUT!

May 6th, 2008

Most of us have left GRPS within the last decade, still attending and/or have brothers and sisters attending GRPS. We know the inside of the school system better than anyone. Why? Because we are a product of it. Use your knowledge and MAKE a change. Today is the GRPS School Board Election. Get out and VOTE!

There is already an overwhelming turn out because our school systems need change.

Voter turnout higher than expected!

Candidate Info:

League of Women Voters Grand Rapids Voters – Candidate Guide

Candidates Discuss Issues Facing GRPS at Board of Education Forum

outside.in Grand Rapids Election News (The first couple articles)

Union role stirs Grand Rapids school board race

Polling Information:

Grand Rapids Election Information – ALL Polls will be open until 7PM, some will be open until 8PM

We’re building the school system for the children of tomorrow, TODAY! Spare 30 minutes of your life to change the life of thousands for a life time!

Best Regards,

AJ

Let inspiration rain

March 27th, 2008

Morning of surprise

August 7th, 2007

For the past month I’ve been getting up early and jogging almost every morning. Well this morning was a bit different because it was thundering and lightening outside. I took this opportunity to use my gym membership which has been frozen since just after the winter thaw. I have no desire to work out inside when it’s so beautiful outside. I jumped in the car, drove down across the river, feed the parking meter, and walked inside. Only to find that my gym went out of business, thankfully it was only this location. When I purchased my membership I was wise enough to make sure they had other locations because I knew gyms have a tendency to go out of business without warning.

It looks like tomorrow I’ll be wandering across town to check out the other location which has been in business for as long as I can literally remember. As for today it looks like I’ll have to wait until the rain stops to go for my daily jog. Which doesn’t look like it’s going to happen anytime soon and when it does it’s projected to be about 85 degrees out. Not the greatest weather to jog in but I’ll survive.

Adventures of San Francisco

April 9th, 2007

It’s been a couple few weeks since I’ve been back from California and figured I better write a post about my adventures in San Francisco while they are still vivid in my mind. Let’s step back in time to the beginning of March. I arrived in San Fran on March 8th an hour or so after sunset. Originally I had planned on taking Amtrak up from Santa Clara but after discovring 511.org I decided to take the Lightrail to Mountain View. While in Mountain View I stopped for dinner at the Tied House (recommended by someone at EclipseCON) where I had the Brewers Burger and a pint of their New World Wheat. Both were amazing and I plan on returning next time I’m that neck of the woods. Oddly enough I ran into Ben Konrath from Red Hat who was also at EclipseCON. Figured once I left Santa Clara I wouldn’t see anyone I knew until I returned home, guess I was wrong.

After dinner I grabbed the next CalTrain up to San Francisco on which I met someone else playing their PSP. Sadly, I had left all my games back home because I accediently grabbed the wrong case on my rush to get out the door. I would of rocked to do some fragging on a train. Roughly an hour or so later I was in downtown San Francisco. I left the CalTrain station and jumped on the BART which dropped me off about 2 blocks from my hotel. Upon rising to the surface I encountered a colorful character who politely gave me directions and a free map. Man what more did I need to look like a tourist, wasn’t the winter coat, luggage and camera a big enough hint. Anyway, since this was his main source of income I kindly gave him a tip and went on my way.

I strolled down Market St and hung a right on Mason. Not paying enough attention to the direction I had recieved (He said on the right not take a right) I wandered up Mason a couple blocks. Knowing I had gone to far or the wrong way I asked the Bellhop at the Nikko Hotel. He pointed behind me at the building with the gigantic stop sign. As I walked away he asked, “Why don’t you bomb the hill on your board?” I replyed, “The luggage wheels couldn’t handle it.” Headed back down Mason I found my hotel. The outside didn’t do this place justic at all. Upon entry it all was redemed, the walls & ceiling were lined with beautiful woodwork and a floating waterfall on the wall. I checked in and went upstairs to my room. Which was your average room aside from the 42″ (my guess) HD TV. Nice little touch aside from the fact I don’t normally watch TV.

After unpacking I went downstairs and got the key for the Business Center. I spent a few minutes checking email and double checked my flight details. Next I headed upstairs to do some running in the cardio room. I put a half hour run on the books. While in Cali I’ve ran pretty much every day. I headed back down to my room where I watched some TV (how could I not it was sitting there taungthing me) and crashed out early. I wanted to get a start on things ASAP.

Goodbye EclipseCON, Hello San Francisco

March 9th, 2007

Today marks the end of EclispeCON and man was it a blast. With over 1,300 people in attendance and a alcohol tab of just under $3,000 how could it not be. I meet a good handful of people and learn a lot as well. I’m looking forward to next years EclispeCON. I figured while I was on this side of the country I might as well do the tourist thing and head up to San Fran. While I’m here I plan to visit Alcatraz, Fishermans Wharf, Chinatown, Golden Gate Bridge, The Bay Bridge and what ever else I can find. I’ll probably visit some museums and what not as well. There is a wine tour that goes up to Napa Valley that I might end up taking. It’s 9 hours long so the only prerequisite is that you have to be hard core wine consiour. Might be a bit out of my league tho. Who am I kidding, it sounds like a blast. I’ll let you know if I end up going or not. If anyone knows of anything else I should do while I’m out here please leave a comment.

PHP Development Tools for Eclipse

March 8th, 2007

Yesterday I had the opportunity to sit in on the “PHP Development Tools (PDT)” talk here at EclipseCON. I haven’t used PDT since it’s inital release last year so it was great to see what they’ve been doing. Yossi Leon the Project Leader provided an overview of the PHP perspective and the various views. Then he went on to demonstrate the debugger which currently only supports Zend’s close sourced debugger protocol. However he did mention that there is a patch for Xdebug support if you’re feeling brave and want to compile PDT. For the most part PHPEclipse provides all the features that PDT does but there are a good handful of features not in PDT that PHPEclipse currently supplies. However, there were a couple neat features that I’d like to see make their way into PHPEclipse. Personally, I attened this talk because I’ve had one question on my mind since Zend proposed a PHP plugin for Eclipse. That question being, “Will Zend be releasing a commerical version of PDT?” Come to find out PDT is NOT a plugin itself but a framework which a plugin can be build upon. After learning this I had to reword my question to, “Will Zend be releaseing a commercial IDE based on PDT?” Which of course the answer to is yes. I was unable to find out when but Yossi did say it should be surfacing soon.

Now knowing this raises another question, “Should PHPEclipse switch to PDT as it’s underlying framework or do we continuing developing the current framework.” This is a question that only can be answered by the PHPEclipse developers and community. I personally wouldn’t have an issue with the switch because Yossi informed me that they will be creating a generic debugger interface to support multiple debuggers. This is something that the PHPEclipse developers have been discussing for quite some time since we have support for both DBG and Xdebug. The only concern left is what influence will Zend have upon PDT because of their interest in developing a commercial IDE upon it. Having a 100% open source project such as PHPEclipse involved in the development of PDT might be a good idea. What do you think should PHPEclipse switch to PDT?

Scott Adams, AJAX Toolkit Framework, Mylar, DTP and PHPEclipse

March 7th, 2007

Scott Adams was the Keynote Speaker to kick off EclipseCON. He started off with a story on how he became an cartoonist and the evolution of Dilbert. Then went into how to be successful and briefly talked about his past. Afterwards he showed some comics and shared a story behind each of the comics on why they didn’t quite make the cut. It was an amusing morning that started off with a ton of laughs.

Next I attended a talk on the AJAX Toolkit Framework. I’ve been meaning to check this out for quite some time but never got around to it because the Firebug plugin for Firefox did everything I needed, or so I thought. I have now come to the conclusion that I was wrong and since have installed ATF. It has all the benefites of Firebug plus so much more. If you’ve never had a chance to check out AFT I strongly encourage you to do so. It just so happens that as I finished writing this paragraph a gentleman came over to the table and set down a handful of CDs from Backbase titled “AJAX Starter Kit.” Quite ironic if you ask me. Looks like I have yet another AJAX pluging for Eclipse to give whirl.

After the AFT talk, I attended “Task-focused programming with Mylar” presented by the Project Maintainer Mik Kersten. I’ve been using Mylar for roughly the last 6 months and it has completely changed the way I work. I have never been so orginized or more productive. Mylar allows you to build a context related to the current task (bug, feature enhancement, etc) at hand and forget about everything else. Thus making it so that when you switch between tasks all the files that are related to that task are reopened, bringing you back to exactly where you left off. No more trying to remember what files, classes, or methods are related to the specific task, Mylar handles it all for you. Tasks are imported from your bug tracking software (Bugzilla, Trac, and a few others) or you can add personal task locally. Task context can also be shared between developers which is an incredible feature. You can also see incoming and outgoing changes to tasks from within Eclipse. Since ATF provides a Mozilla implementation I no longer have a reason to have Firefox open. Now that I can update tickets in Trac and view what I’m working on from within Eclipse. Mik provide a detailed look at what can be done with Mylar and what to expect in the upcoming 2.0 release. He also annouce a new partnership with Tasktop which extends Mylar bringing it’s functionality to desktop applications such as your email client, web browser, word processor and web services. Which will allow you to add context outside of Eclispe related to a task. This plugin is a must have for every programmer.

This talk was followed up with a long awaited lunch which. After I attended a talk on the Data Tools Platform Project (DTP) which was very interesting and I learned a good deal on the internal workings of the plugin. Including how to create my own dialect for a RDBMS. I wish I could of stayed for the entire talk but my presence was required at the Open Source Pavilion causing me to have to leave about a half hour early.

In the Open Source Pavilion I had the opportunity to demo PHPEclipse for roughly 6 hours. No sooner did I sit down and setup the laptop did someone show up for a demo. Just as I was in the final moments of my first demo John Ward (presented the tutorial I attended on Monday) stopped by. I was expecting him because on Monday I had mentioned to him that I would be doing demos of PHPEclipse on Tuesday. It just so happened that he was working on a PHP project and was looking for a PHP plugin with a functional debugger. All the ones he tried including PHPEclipse he couldn’t get the debugger to work properly. Being the debugger guru that I am from the past couple of years spent on IRC helping people setup PHPEclipses’ debugger. I had him well upon his way to debugging bliss after about a half hour, he couldn’t of been happier. I continued to demo PHPEclispe to several more people and finally the person I had been waiting for showed up. I knew eventually someone of the Zend would stop by and that someone did.

He admitted right off the bat that he had never looked at PHPEclipse and told me he was one of the QA people for PHP Development Tools (PDT). After which he asked if I’d be kind enough to give him a tour which I delightfully accepted. I started off with an overview of the workspace layout which he complimented on how intuitive it was. Next, I explained how the code completion and syntax highlight worked and finally I did an in depth demo of the debugger. The only thing he had to say as he left was PHPEclipse was very impressive. So far this has been the highlight of the conference for me. It’s always nice to demo a product for a competitor and them being blown away. Now I have no choice to return the favor, as I finish writing this I am on my way to the PDT talk.