Posts Tagged ‘php’

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, 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.

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.

Life is Good

Wednesday, August 17th, 2005 at 1:30 am

Things have been going pretty well lately. Financially, I’m doing OK. I’m buying Becker’s Saturn next week, and I’ve got plenty of money set aside to buy, insure, and register it. The Apple loan is paid off, so I can put a decent chunk of my last couple paychecks to the credit card bill.

I’m working on a new project at work for the big plasma screen in the college lobby. One of the secretaries in the Dean’s office makes slides to show on it, but the system is pretty crappy, so we’re re-writing it to just show a web site we’re designing. I’ve been working on the client side, to make use of templates and styles that we’ll define so she can build slides. It’s been a lot of PHP and JavaScript, so I’m happy.

Classes are starting soon, which means people will be coming back from break in a week or two. I have never seen our parking lot so empty; apparently, most people go home for this break. It’s the calm before the storm; RJ showed up yesterday, and I hear the RA’s are starting to come back for their training. Another week or two and everyone will be back.

I’ve gotten over the whole graduation thing. Usually, I only get stressed about money, when I realize I’ve got $1.64 in the bank and a $50 bill due in four days. I freak out for about 10 minutes before I convince myself that everything has worked out in the past, so it’s sure to do so again. And it has - worrying about it has never fixed the problem, so I don’t bother. My anxiety about leaving for the real world was a little more profound than that, but I’m over it. Things are going too well to worry much about what will happen a few months down the road.

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.