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
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
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
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
jQuery Random Color Changer
So I had a lot of time on my hands today, and we were trying to figure out a good color palette for one of our customer service portals. Since I'm not in the least bit a designer we decided to wait for one of the Graphic Designers to take a stab at it, only problem with that is they were out to lunch. So someone gave me the idea to play around with the colors and make them change from time to time. I wasn't feeling particularly ambitious so I scoured the internet for a good jquery solution to randomly select colors and change background colors based on those that were randomly generated.
below is what I came up with:
/* -- jQuery Colourific */ /* -- v 1.0 - January 2008 */ /* -- by ben watts (http://www.benwatts.ca/sandbox/jquery-colourific/) */ //$(document).ready $(function(){ setupColourific(); }); // setupColourific function setupColourific(){ var elements = new Array(); elements[0] = $("td.Upload"); // the element that's changing elements[1] = $("td.Notes"); elements[2] = $("td.LoanTitle"); elements[3] = $("td.hdr"); elements[4] = $("body#body"); for(i = 0; i < elements.length; i++){ changeColour(elements[i]); } window.setInterval( function(){changeColour(elements[0]);}, 1000); window.setInterval( function(){changeColour(elements[1]);}, 1500); window.setInterval( function(){changeColour(elements[2]);}, 2000); window.setInterval( function(){changeColour(elements[3]);}, 2500); window.setInterval( function(){changeColour(elements[4]);}, 3000); } // changeColour function changeColour(e){ // random values between 0 and 255, these are the 3 colour values var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); // puts the hex value inside this element (e is a jquery object) //e.text(getHex(r,g,b)); // change the text colour of this element e.css("background-color", getHex(r,g,b)).fadeIn(); } // intToHex() function intToHex(n){ n = n.toString(16); // eg: #0099ff. without this check, it would output #099ff if( n.length < 2) n = "0"+n; return n; } // getHex() // shorter code for outputing the whole hex value function getHex(r, g, b){ return '#'+intToHex(r)+intToHex(g)+intToHex(b); } |
Obviously you'll need to change the selectors to something relevant for your purposes. It's probably not something you want to use on a regular basis but would make a great april fools day joke, or if you feel like a ceasure go ahead and mess with the time interval.
I can't take full credit for this script, the original can be found at This site
Print This Post
Handy PHP trick I learned today.
Nice to see the Dev blog is still here, and that I can remember my login. Here is a useful debugging trick I learned for PHP, hopefully it's not in one of Phil's link posts.
echo '<pre>'.print_r($app,true).'</pre>';
this bad boy will give you all of the values of an array, variable etc.
more to come soon.
Print This Post
jQuery vs. Prototype
Got a sample article from NFJS that looked at the two libraries. Thought everyone might enjoy having a look at it. I thought it was pretty good if a little long winded. DETAILS only FTW!
Ajax Library Smackdown: Prototype vs jQuery by Nathaniel Schutta
Print This Post
Firefox 3.6 Released – and a css fix for it.
Firefox 3.6 dropped today, and I jumped on board and installed it immediately. Then to my surprise, shock, and horror, my favorite Firefox CSS fix failed. a:focus{ -moz-outline: none;} no longer works in 3.6. I tried google-ing (futile effort on the day of the release might I add) for a solution and nothing. But fear not, I played around and found one.
instead of a:focus { -moz-outline: none; } you use a:focus { outline: none; }. Seems that they no longer require a Firefox only declaration (although you may want to use both -moz-outline and outline so that less-than 3.6 users still don't see those fun dotted boxes).
Print This Post
