Archive for the ‘Web Development’ Category

2008 DC PHP Conference & Expo

Sunday, February 10th, 2008 at 12:12 am
DC-PHP 2008 Logo

This year’s DC PHP Conference & Expo is going to come earlier than last year’s: June 2-4, rather than in November. I’m hoping to go again, because it was pretty interesting and informative last time, and I’m sure this one will be even better. If you’re a web developer in (or near) DC, consider registering - or, better yet, submit a paper!

CakePHP: First Impressions

Sunday, February 25th, 2007 at 12:22 am

About a month ago, I spent some time (more than I should have, really) getting Ruby on Rails running on my laptop so I could run through this tutorial on Apple Developer Connection. Ruby on Rails has been heralded as The Next Big Thing for about a year now, and I figured it was time to get on board. After all, PHP developers are most likely to switch, so I had to give it a shot.

I understood the concepts, but the fact that I’ve never even seen Ruby code (let alone written it) made it a little hard to follow. Was I willing to learn a new language to use the framework? If it would save me time in the long run, sure. But, at this point, I don’t really feel like I have a lot of time to be putting into new languages. I wanted the ease of development without such a heavy time investment upfront.

Thus: CakePHP. I know PHP. I’m reasonably comfortable with the MVC framework. And, as it turns out, Cake is real easy to set up. Their manual could use a little work - a lot of it was “Scaffolding makes things easy!” rather than “This is how you set up scaffolding.” Thankfully, the blog tutorial was more helpful than the rest of the manual (the parts I’ve read, anyway), and there’s a fairly significant Cake community writing articles and how-to’s all over the place. I later found out that scaffolding DOES make things easy (if not pretty) - I created a users table, two files with under a dozen lines of code between them, and I’ve got a super-basic user management utility. Obviously, I won’t be using it in the real world, but for quick prototyping or a basic placeholder for more advanced functionality, it’s great.

So that’s good news. I think I’ll be using it for that project after all. And, putzing around with it this afternoon taught me a few other new things. I had been meaning to set up a Subversion repository somewhere for a while now. In the past, I’ve used RCS for a few projects so I could roll back code if I screwed it up good, but it’s a pretty crappy solution. I spent about ten minutes trying to find SVN server software for the Mac before it occurred to me to just try svnadmin create /svnroot. I also found the language association drop-down in TextMate - it’s right there at the bottom of the window, by the way - so now it knows my .thtml Cake view files are actually PHP and colorizes appropriately.

I didn’t get much code written today, but I’m in a better position to get more done from here on out - I’ve got a good framework, a code repository, and I’m becoming more comfortable with my editor. Sometimes, you just need to take a day for all this extra crap, so that the coding part goes a little quicker and a little smoother.

And now, if you’ll excuse me, I’m going to crash. I slept about ten hours last night and took a three-hour nap this afternoon when I had a bad headache, and in spite of all that, I’ve had trouble keeping my eyes open for the past hour. I really hope it’s not my turn to get sick.

CakePHP, Anyone?

Thursday, February 22nd, 2007 at 10:26 pm

I know that I don’t have too many readers, but still: have any of you used CakePHP?

I’ve got a side project that I’ve just started with a pretty short time frame. I program against an MVC framework at work and would like to build something similar for this project. Unfortunately, their server is running PHP 4.4.2, which makes things a little tougher (I use 5 daily at work, so I’m accustomed to full OOP capability). It’s do-able, but I don’t want to waste a lot of time getting a framework established. From what I’ve been able to find, CakePHP has a bit of a learning curve, but will make things a lot easier to manage in the long run. The problem is that I can’t find any decent testimonials about it (even tried Jyte). What I need is someone who can say, “It’s good for this reason and sucks because of that.”

Unless I find some reviews, I’m going to spend tomorrow evening playing with it. If things don’t go well, I’m down a day, but at least I’ll know whether it’s worth pursuing.

PHP, Zend, TextMate, and Code Completion

Tuesday, February 20th, 2007 at 10:40 pm

I spend most of my day coding PHP, so Zend Studio is like my Holy Grail. I had never even heard of it until i started my current job; we got it shortly after I started, and I’ve used it daily since.

The wonderful thing about Zend is its code completion. If I type strp, it will suggest strpos and strptime. When I hit Enter or Tab to select strpos, it finishes the function name, adds parenthesis, and in a little box above the code, it tells me strpos(string $haystack, mixed $needle [, int $offset]). And it’s the greatest thing ever.

I know how to program, and obviously, I know how to program in PHP, or else I wouldn’t be doing it for a living. However, there are very few compelling reasons to know every built-in function and the arguments they take; it’s far more important to know what that function does and what it will return. I know what strpos() does, and I know that it will return a boolean FALSE if $needle isn’t found in $haystack, and that it can also return 0 (which evaluates to FALSE) if $haystack begins with $needle.

Knowing these details is important, but I use strpos infrequently enough that I can never seem to remember whether $needle or $haystack is the first argument. With Zend, I don’t even need to think about it, so I can focus instead on what I’m doing, what variables I’m using, and what code needs to come next.

Of course, I don’t even really need to remember what variables I’m using, since Zend knows those, too. It also builds an index of all functions, classes, variables, and defines that I’VE written - not just the built-in ones - so I don’t need to remember much of that, either. Obviously, it’s quicker if I’m familiar with them and don’t have to rely on auto-complete for everything, but it sure as hell helps. How often is the source of frustration a $filename where it should have been $fileName? In Zend, I type $filen-tab, and it capitalizes the N and finishes the variable name for me.

Some programmers would argue that this isn’t “real” programming, since I’m relying on the software to tell me what to do. Some programmers would argue that the first group of programmers is a bunch of self-righteous Linux geeks and why don’t they just move out of their mom’s basement fer crissakes. I, of course, am in the latter camp.

Zend has significantly improved my productivity by allowing me to keep programming without switching over to documentation very often. Everyone has to RTFM every now and again, but the less I have to do it, the faster I can get things done. Even with the code hints, I still need to check php.net a few times a day (for example: the arguments for str_replace are $search, $replace, and $subject - is $search the thing I’m looking for, or the thing I’m searching through?)

Now, Zend isn’t all puppies and rainbows. It’s based on Eclipse, which was built in Java, which I’ve never had much luck with. On my PC at work, it’s a memory hog, and on my iBook, it’s barely usable. My work machine is pretty beefy, so it’s really not a problem there, but working from my Mac can be a real pain. On top of the speed issue, the fonts occasionally get messed up: the cursor appears somewhere it isn’t, so keystrokes affect some other area on-screen. I haven’t figured out what causes it, but I have to restart Zend whenever it happens (which leads me to another gripe: Zend takes forever to start).

Enter TextMate. Mac-happy developers have been in a tizzy about it for a few months now, but I finally started playing with it a couple weeks ago. It’s fast. It seems to be stable. The open-file tabbing is much better than Zend on the Mac. And, if you run it from Terminal with mate dirName/, it will load that directory (and any new files created in it while TextMate is open) into it’s file browser thingy. Zend has a similar file browser, but it’s not file system-aware (is that a real phrase, or did I make it up? Either way, you know what I mean).

However, it too has its downfalls. It doesn’t support open/save over FTP. And, much more importantly, it doesn’t do code completion.

I did find a PHP code-completion bundle, which has helped a bit. I type strp, and when I hit Escape, it suggests strpos (another Escape, and I get strptime). It’s a start, but it doesn’t know anything about arguments. You can hit Shift+F1 to go to the PHP manual for a function, but who wants to keep going back and forth like that? Furthermore, it’s only good for built-in functions - no functions I define, and no variables.

My TextMate trial ran out today, so I coughed up the $50 for a license. I’m hoping that I’ll find a bundle (or something) to soothe my code-completion addiction, but even if I don’t, it’s a good editor. In the meantime, I’ll probably commit more argument details to memory and get used to visiting php.net. I’m starting to do more development on my laptop (another big help: MAMP), so I think it’s going to be worth it.

Plus, that’s $50 I can write off come tax time next year. Right?

Super Hack-ey iTunes Playlist Hack

Tuesday, April 11th, 2006 at 7:07 pm

For those of you who were interested, I posted my quick and dirty hack to fix my iTunes playlist woes. It won’t re-create the playlists, but I got the information I wanted.

And yes, I know it can be done in a few lines of Perl, but I know PHP much better than Perl, so this was the quickest (and easiest) way for me to do it.

JavaScript, JSON, and PHP

Thursday, January 26th, 2006 at 9:24 pm

John first mentioned JSON about a month ago, but at the time I had no inclination to look into it and find out if it was something I could use. It came across my radar again today thanks to a Particle Tree article that I never finished reading, but that’s not important. The long and short of it is that JSON is really just a fancy name for eval-ing JavaScript objects - one of those “why didn’t I think of that” kinds of things.

The few times I’ve tried using Ajax, I’ve spent most of my time fighting with XML parsing (or convincing IE that it was XML I was trying to parse), so the allure of native JavaScript objects was enticing. I talked with one of the guys at work about writing a function in PHP that would take an array and generate the appropriate code, until I came across the (seemingly de facto) “official” JSON page. He’s got references there for pretty much every language you’d expect to do web development in (and a few you wouldn’t) - including JSON-PHP, which does exactly what I was going to. Couple that with Prototype’s quick-and-dirty Ajax.Request, and you’ve got a Web 2.0 application quicker than you can say “What the hell is a Web 2.0 application?”

QuirksBlog has a pretty good post comparing JSON, XML, and HTML snippets, if you’d like to further consider your Ajaxing options.

Prototype

Saturday, January 14th, 2006 at 1:39 pm

Anyone who does any JavaScript development should give the Prototype framework a try. It provides a lot of helper functions that replace a lot of code. For example, there’s a $() that effectively calls document.getElementById(), but allows for several arguments and will return an array of elements matching those IDs. A few functions handle form access and processing, and there are a handful of AJAX functions I haven’t tried yet. It’s nothing that I couldn’t do on my own, but it makes things much easier. I just started playing with it at work yesterday, so I haven’t found out what it can really do, but I think I’ll be using it for other projects.

Unfortunately, the official site has next to no documentation. The code is simple and clean enought that reading it is enough in many cases, but it’s not all too clear. Thankfully, plenty of people have come before me, so there’s some decent information out there. The two I found most useful were Particletree’s introduction and Sergio Pereira’s guide.

Found Comments

Tuesday, December 6th, 2005 at 9:53 am
// The number of values may vary but must always be a multiple of 2 plus 1.

Or, “odd,” if you will.

XMLHttpRequest is Sexy

Monday, March 7th, 2005 at 1:12 am

So, after complaining a bit about XMLHttpRequest, I did some looking around today to see how big of a pain in the ass it would be.

Turns out, not very.

I spent a couple hours fighting with a test page, until Resig pointed out that I needed to specify text/xml as the content type for the XML document (thanks again, John). From there, I just needed to touch up the JavaScript a bit to get it working the way I wanted it to.

I’m pretty psyched about the prospects of this whole Ajax business. It’s a lot easier to do than I expected it to be; the most difficult parts come in with DHTML, for the most part. My JavaScript skills could use polishing anyway, so I’m planning to re-write the segfault editor (members only, sorry) I did last year in PHP. To begin with, I might clone Ta-da List, just to get some practice before throwing myself at the bigger project.

I never liked the idea of relying on the client to provide processing. PHP always seemed safer because it runs server-side, so you don’t have to worry about the user disabling JavaScript or running an ancient browser that doesn’t support it. By now, most users have upgraded to at least IE 6 or (hopefully) Mozilla Firefox, so this is where the web is headed. If some really cool sites hadn’t already shown off the capabilities of the technology, I probably would have dismissed the idea entirely. Thankfully, some talented people got to it before I did and convinced me it’s worth tinkering with.

XMLHttpRequest

Sunday, March 6th, 2005 at 2:39 am

This has been on my to-learn list for, well, about two weeks. Even so, it’s been at the back of my mind, pushing everything else out, because this industry moves fast and furious-like, so I need to get on the band wagon.

I stumbled onto this post thanks to Lazyweb, and I think he sums up my feelings quite nicely:

google is no longer about search. they are about making everyone that doesn’t work for them feel bad. i mean, google suggest was awesome. blew my mind. it was like magic. we now know that was only a warning shot. then they blew everything out of the water with google maps. but now the rest of us, who fancy ourselves web developers, just feel bad. like now i’ve got to go back to school and get a proper education. or find something else to do.