Zend Framework vs. CodeIgniter
I hope nobody minds but this is going to be more of a rant than an actual performance comparison of the two frameworks. First of all I started using CodeIgniter almost two years ago, and while it was a bit of a thorn at first it was never super difficult to figure out how to do stuff. The documentation was easy to understand and full of examples of what to do, plus things worked when I did them. As a result I've used CodeIgniter on several projects since.
Recently at my current job the powers that be (hereafter referred to as "they") decided to go from a progressive coding approach to a more MVC type approach using a framework (either custom made or already built). I'd like to point out that I'm all for using a framework especially on the applications we've got right now. I did suggest CodeIgniter as the framework of choice but my suggestion was received with disgust, so I kept my mouth shut...big mistake.
After attempting to build their own MVC Framework "they" decided to go with Zend Server Community Edition. Now I didn't (and still don't, which is sad) know a lot about the Zend Framework so I was somewhat excited to see it in action, especially since my experience with CI has been so great. And I guess maybe that's one of the reasons I'm posting today.
For anyone out there wondering if Zend is a good match for you, STOP!
For anyone out there who recently implemented the Zend Framework, WHY? It's not to late to turn back.
I've been working with the Zend Framework for about two weeks now, and I don't expect to know everything there is to know about Zend but I do expect to know SOMETHING. Let's just take a trip down memory/nightmare lane.
Please excuse me if I can't remember all the details, I've tried so hard to block some of this from ever resurfacing.
My first task was to figure out how to ajax with zend, seems simple enough right? Shoot zend even created a helper that loads the (almost) latest jQuery libraries for you so you never have to worry about being up to date. Not only that but zend has a way to build your Ajax request so you don't have to know how to do that yourself either. What they don't tell you is that in order for the jquery libraries to be loaded on your page, you DO have to use at least one of their custom php jquery building tools (in other words, you can't make all your jquery by yourself), otherwise the libs just wont load. Instead they let you beat your head against your desk for hours and hours until you finally un-comment a test jquery builder you had previously used only to find out that was the missing piece.
Next our whole team has been tasked with creating a new application using zend, it's been over a week now, I still feel like I don't know anything. Now you might be saying to yourself, "did you try google dipstick?" Yup sure did, and as google does it pulled up all kinds of links. Almost always the top 5 go strait to the official zend documentation which is by far the worst documentation I've ever seen about anything. It's like when someone has a secret and they know you want to know, but they know that if they tell you then they'll lose the leverage they have on you, so they just hold on to it with that smirk on their face and never tell you anything. There's all kinds of words but they don't say much and the examples are horrific at best. One example I was looking at had a variable in it, and they'd conveniently cut out the part where they actually initialize that variable so you have no idea what values it is supposed to hold. Turns out it was an array, but I still don't know if it was a named array or if it can simply be numbered. I actually got a little excited when I stumbled onto the Programmers reference guide, I thought "yes if anything will help this is it", I was wrong to think that and I apologize.
Now here's the kicker, I do need to backtrack a bit. When you install zend there is a GUI that is installed to help you manage how the server works, I've recently lost this GUI, by lost I mean I know where it's supposed to be and the files are all there but the GUI doesn't show up when i put the correct URL in my browser. So I started researching this, only to find that a certain part of the server called lighttpd is not running, the GUI is the only thing that requires lighttpd. So i started googling lighttpd is not running and got a fair amount of hits on that one. None of which helped. Finally I decided to create an account with the zend forums and humbly ask the zend folks themselves what to do about my problem.
To my dismay, when I logged in I found a little counter at the bottom of the page that said "Users browsing this forum: disgruntled and 0 guests" (if you haven't guessed, I'm 'disgruntled'). You have got to be kidding me, I'm the only one on this forum? Now to be fair it was after 5:00 on the east coast so I imagine the 3 people using zend in that part of the world have gone home.
Needless to say, I'm a little disappointed, awe who am I kidding? I'm downright furious.
On the flip side, if anyone reading this has any idea on where I can get my hands on some useful examples of zend at work. Please leave them in the comments.
Print This Post
How to run OSX from a USB drive
The Problem:
If you've read some of my previous posts, or followed my twitter feed, you'll know that my iMac died. After running as many hardware tests as I knew how to run, I determined that the hard drive was dead. It then sat on my shelf for a few months and I finally decided to fix it so I could either use it (to keep the kids off the other computer) or sell it. I took it to my local mac shop (no Apple store out here), and wouldn't you know it, they claimed that the file system structure was hosed, but that they fixed it.
Unfortunately, they were full of hot air and I was left (again) with an iMac-shaped paper weight. I ran a few more tests and found that yes, I was right, the drive was toast. So I did what any rational technologist would do, I googled the ever-loving goodness for how to run OSX from an external hard drive.
What I was left with was rather disappointing, a deluge of how to put the installation of Snow Leopard on USB drives and install from them (yes, I know it's not actually disappointing , it's really a rather cool thing, and a good solution to backing up your installation DVD, but that's not what I needed). So taking a blind stab in the dark, here's the method I came up with.
Print This Post
Use PHP to Build an Array of ‘Times of Day’
It's been a long time since I posted so I find it ironic that "time" is what brings me here today. Ok that was pretty corny. You'd think this would be something that would be pretty easy to find on the web, I was a little shocked there wasn't some post about it in the PHP manual but there wasn't so here it is. I was looking for a quick way to build an array of times of day starting with midnight and increasing every half hour until 11:30 PM (or 23:30 for you G.I. Joe's). PHP has an abundance of time functions that are all very useful in their own unique way. After trying various different ones i finally came up with the following.
//build array of times. $times = array(); $time = strtotime("00:00:00"); $times["00:00:00"] = date("g:i a",$time); for($i = 1;$i < 48;$i++) { $time = strtotime("+ 30 minutes",$time); $key = date("H:i:s",$time); $times[$key] = date("g:i a",$time); } |
To break it down, I set $time to start at Midnight or 00 Hours and then set my first $times array member to the lamens "12:00 am" using the date() function. Since there are 24 hours in a day I know there are 48 half hours in a day so I set my loop to run 48 times.
Lets break down the loop:
$time = strtotime("+ 30 minutes",$time); |
This will add 30 minutes to the $time variable each time the loop runs.
$key = date("H:i:s",$time); |
This sets $key to the military notation of the current $time (the why will become more obvious later).
Finally I set my next $times array member with:
$times[$key] = date("g:i a",$time); |
Again the value of this member is set to the ordinary am/pm notation.
If you were to look at an array member in plain text it would look something like this:
$times["19:00:00"] = "7:00 pm"; |
Pretty simple, now just to display it. For my purposes I chose a select box.
<select class="required" name="CloseTime"> <option value="">--Select--</option> <?php foreach($times as $key => $value) { ?> <option value='<?php echo $key; ?>'<?php if(isset($CloseTime) && $CloseTime == $key) echo " selected='selected'"?>><?php echo $value; ?></option> <?php } ?> </select> |
Since I set up my $key as military notation I am able to use $key as the value of the <option>. I did this so I can easily put that value in the DB as a TIME and not have to worry about stripping the " am" and " pm". Alternatively since $value was set up with am/pm notation it displays nicely to the user as 7:00 PM rather than 19:00 thus allowing regular Joe to keep his fingers in his nose rather than use them to figure out what time that is.
Print This Post
PhoneGap – The missing android/windows setup guide
The Introduction
Yesterday I spent a good part of the day setting up the absolutely fantastic framework PhoneGap. If you don't know what PhoneGap is, and you are a web developer, you are truly missing out. The only thing I can compare it to (from a high level) is Adobe Air. Air lets you build a page out of html, css, and js and then renders it in a webkit self-contained browser that you can then package up and distribute on any platform that runs air (Win/Mac/Linux), and yes you can also build Air apps with Flex and Flash. PhoneGap is similar to Air as it too uses html, css, and js to build apps for Android, iOS, WebOS, Blackberry, Symbian, and Nokia.
Now don't let my title fool you, there is a guide (and a pretty good one at that) waiting for you in the PhoneGap Wiki, the problem is that it is now out of date and will cause you grief if you try to follow a few of the steps because they look like they are the right steps to follow. That's why I've created this entry to walk you through the mistakes I blundered through to get it set up and working on my Windows 7 box (My mac died, and my linux lappy is a netbook - not ideal for developing on... plausible, but not ideal).
Print This Post
Quick and Painless file conversion
It's pretty rare that a person needs to convert one file type to another (especially since programs like OpenOffice.org will open just about anything). However today I got a file with a .wps extension, my first thought was 'maybe that's a word perfect' so I tried to open in w/ OpenOffice writer which gave it it's best shot only to come up way short by opening a blank page.
I promptly went to google to find out what extension that is and not only did I find it's an old Microsoft Works file that is no longer used/supported, but I also found a handy website for converting such files (among others) to more user friendly formats.
The site is called zamzar.com, all you do is point your browser there (or click on the link) upload a file and within a few minutes you have an email with a download link to your new file, it's easy, fast and best of all free. You don't even have to create an account, although there is that option. I was so impressed with it I decided to post it here on my favorite tech blog.
Print This Post
Site changes
A quick note, I've been playing with themes lately (I keep telling myself that I'm going to actually code one, but it never happens) so keep that in mind if the site keeps changing on you. I'm just trying to find a style that is pleasing to the eye, and works well for most visitors.
Print This Post
LinkPost – Jan through April 2010
It's that time again. The time when I make good on those promises of finally posting all the backed up LinkPosts
. The first quarter of this year has been fairly amazing, Google has started to include speed in page-ranking, jQuery released 1.4, and css3 is starting to build some serious momentum. There are links to all of that and more in this massive LinkPost
Print This Post
Configuration is frozen
While in your Java development journey, if you find yourself getting an Error 500 NullPointerException and your console shows "IllegalStateException: Configuration is frozen", you could be the victim of what I experienced this week.
I wanted my forwarding to actually redirect to a new action so that the decorator would be applied to the new action instead of the current one, so I tried this approach:
forward = mapping.findForward("blahblah"); forward.setRedirect(true); |
This doesn't work. The reason is because the forward that you are using is defined in the struts config file, so you are attempting to modify an existing forward. This is not what you want to do because it will affect ALL future uses of that forward, hence the error. Here is the correct way to accomplish this:
forward = new ActionForward(mapping.findForward("blahblah")); forward.setRedirect(true); |
UPDATE: An astute reader pointed out that this is probably only an issue if you haven't set redirect="true" in your struts config, and that you should always set redirect to true if you are forwarding to another action anyway. Good catch Casey!
Print This Post
Using jQuery to Make a Smart Search
Recently I've been forced to develop a relationship with jQuery (something I had no interest in while I was working with team awesome). I have to admit it has been quite pleasant and my tolerance has grown into a very strong liking of the library (so I'm a little slow). This proved very useful when I was asked to make a search field do more than just search for an ID. I decided NOT to fowl up our nice sleek looking header with a clunky drop down box, instead I turned to jQuery to make the search bar intuitive...observe.
$("#searchForm").submit(function() { //the regular expressions in this function are not meant for validation as much as determining which value to search by. var submitted_appid = $(".search input[name=AppID]").val(); if(/^[\d]+$/.test(submitted_appid) == true) { //do nothing since the input is already properly named } else if(/^[\d-]+$/.test(submitted_appid) == true) { //change name of input to SSN $(".search input[name=AppID]").attr("name","SSN"); } else if(/^[A-Za-z]+$/.test(submitted_appid) == true) { //change name of input to LastName $(".search input[name=AppID]").attr("name","LastName"); } else { //no match, alert the rep and return false alert("invalid search value:\nfor SSN please use numbers and at least one dash '-'\n for LastName use only letters\n for AppID use only numbers") return false; } //there was a match add an action and submit the form. $(this).attr("action",'search.php'); $(this).submit(); }); |
The HTML
<div class="search">
<form id="searchForm" name="searchForm" method="post" action="">
<input type="text" name="AppID" value="Search..." />
</form>
</div> |
Then your search app would do something like the following
if(isset($_POST['AppID']) { //enter sql code here } else if(isset($_POST['SSN']) { //enter sql code here } else if(isset($_POST['LastName']) { //enter sql code here } |
Basically the jQuery decides what to search on based on the characters in the input field, if the wrong mix of characters is present then we fire off an alert message notifying the irresponsible party and correcting their ignorant ways.
Print This Post
