6 Ways To Kill Your Servers – Learning How To Scale The Hard Way
Good article over at HighScalability.com about what happens when a coder, even an experienced one, has to scale out a web site under time pressure.
The most important lessons in my opinion are caching, tweaking configuration and stress testing.
Private methods in PHP programming – response
Felix over at Debuggable wrote an interesting article about private methods. He thinks it's not a very good thing to use, but, kudos to him, doesn't rule out the possibility. He argues that he doesn't have any formal education in programming and development, but I don't think that matters much at all since he seems to have quite a bit of programming experience.
But what I think is that, of course, you alwas can write private-method-free code, but sometimes it's not very good. When you need to duplicate code time after another, you might begin to see the need for another method (refactoring) or for that matter class. What that method does or returns maybe, just maybe, isn't that good for the rest of the world (read application) to access directly rather than through your other, more high level methods.
CakePHP itself is has lots of private methods. Could we do without them all? Of course we could. Would it make the code easier to read? Maybe. Would it make the code easier to maintain? I think not.
With that said, you always need to make an active decission whether you choose to make a method public, private or protected. Chances are, if you only write public because you are used to it, you might be making a mistake that could compromise stability or security of your application if another developer makes use of that method...
No 404 page when using a static front page
I was setting up a wordpress blog (latest version, 2.5) a couple of days ago, and added the great plugin Google XML Sitemaps. I wanted a static frontpage with a couple of blog posts below it, so I modified the Kubrick theme a bit (added another template to use for that page, no biggie).
When taking a look at Google Sitemaps (somewhere under Google Webmaster Tools) I found that WordPress didn't respond to non-existing pages with a 404 not found, but all my pages after each other, rather like the posts on a dynamic front page.
Again I thought - no biggie! I modified the 404.php template to begin with the following:
<?php
ob_start();
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
...
Still, no luck. Then I saw that WordPress didn't even read the 404.php page! I tried turning off the static front page and voilà, 404 works okay again.
I've searched a bit for this in the WordPress forums, but I'll report a bug ticket for them. Hopefully it will work in the next release 🙂
Newsflash:
It only works this way if you haven't chosen a "Posts page". Maybe it's just an undocumented feature?
Symfony development with XAMPP on Windows
This is how I set up my windows laptop for development with Apache/MySQL/PHP/Symfony (XAMPP with Symfony).
- Download XAMPP Installer package.
- Install XAMPP - this is really just a case of next -> next -> okay.
- Since I'm not only using my laptop for development I chose not to start any services except for XAMPP when windows starts.
- Start (from XAMPP Control Panel) Apache and MySQL (and whatever other services you need).
- Add PHP to your PATH.
- Right-click "This Computer", choose properties.
- Advanced tab -> Systam variables (not sure, my system is in Swedish 😉 )
- Add C:\xampp\php;C:\xampp\mysql\bin (if installed in default location) to the PATH variable.
- Upgrade Pear - pear upgrade pear
- Find Symfony - pear channel-discover pear.symfony-project.com
- Install Symfony - pear install symfony/symfony
- Done! Start playing around...
Symfony Project
Symfony är ett PHP-framwork som verkar riktigt nice. Finns även en del bloggartiklar här och där som tipsar om bra sätt att göra saker på.