Downloading Files from Faspex

This week, someone sent me a very large file using something called faspex. To begin with, it sent me a link to click on to download my file, but then started telling me “for best results, install a plugin”. And apparently “for best results” means “to download this file in any way”.
Continue reading

PHP Recursive Function Example: Factorial Numbers

I spun up the simplest example I could think of to illustrate a recursive function to a PHP beginner the other day, and I thought I’d share. I often don’t post really basic content but I should – people are beginning to be beginners all the time, after all!

Factorials

Factorials are a very easy maths concept. They are written like 5! and this means 5 * 4 * 3 * 2 * 1. So 6! is 720 and 4! is 24.

6! is the same as 6 * 5!, or 6 * 5 * 4! … and this is where the recursive functions come in. Continue reading

How the Web Looks to Me

It feels like I’ve tried to field the question about how I can use the web without using a mouse (or trackpad or equivalent), without “pointing”, multiple times in the last couple of weeks. The answer is quite visual so I thought I’d share. This is how the web looks to me:

I navigate the web using the Keyboard Navigation extension in Google Chrome, which is what is adding all the little labels you see in the screenshot above. Install the extension, and press comma. The labels will pop up, then you type whichever character(s) show next to the thing you want to “click” on, and off you go.

It’s super-simple, and easier to use than I expected. Why don’t you try it out on your own sites? You’ll get a sense of how the web looks from where I’m standing :)

Speaking at OSCON 2012

In July, I’m speaking at OSCON. Actually I have a few interesting speaking engagements coming up, and I haven’t got around to adding upcoming dates to my blog yet but I’ll be at phpDay in Verona next week with a talk on API Design and DPC in Amsterdam in June with a tutorial on Web Services and a talk on what OAuth is actually for.

OSCON is special because I have always wanted to go and never imagined it would actually happen. Every year I read the list of sessions from the year before, and decide that I absolutely must submit to the call for papers, regardless of how small I think my chances of being accepted are! I’ve submitted a couple of times in the past, excluding last year because I was newly freelance (OSCON does not cover any speaker expenses at all, they just give you a conference pass. That’s kind of hard going for those of us self-funding halfway across the world, and last year, I just couldn’t do it. This year I still can’t really justify it but I’m going anyway!) Continue reading

Using an Existing Vagrant Setup for PHP Development

I’ve been hearing great things about puppet, chef, vagrant, and friends for a while now, but since I work on my own I tend to either develop straight onto my ubuntu machine or grab an appropriate existing VM and use that. So I read about this brave new world of virtualisation but (as with most tools) they can be hard to introduce on your own, and I didn’t.

Then I went to WhiskyWeb, which had a hackathon. I’m unclear on exactly what happened because my attention was elsewhere but it seems like @JayTaph showed off puppet and vagrant to @deizel*, who immediately built a vagrant setup for joind.in, which is an open source project that I’m currently leading. With the shiny new technology all packaged for me, I decided it was time to take a look! Continue reading

We Don’t Know Deployment: A 4-Step Remedy

Someone emailed me recently, having read my book and wanting some advice. Here’s a snippet of his email:


So here’s my problem.
We dont know deployment. We work from same copy on one test server through ftp and then upload live on FTP.

We have some small projects and some big collaborative projects.

We host all these projects on our local shared computer which we call test server.
All guys take code from it and return it there. We show our work to clients on that machine and then upload that work to live ftp.

Do you think this is a good scenario or do we make this machine a dev server and introduce a staging server for some projects as well?

I wrote him a reply with some suggestions (and my consulting rate) attached, and we had a little email exchange about some improvements that could fit in with the existing setup, both of the hardware and of the team skills. Then I started to think … he probably isn’t the only person who is wondering if there’s a better way. So here’s my advice, now with pictures! Continue reading

Apache Config: .htaccess or Virtual Hosts?

How to set apache configuration for your web projects? Some settings have to be in the main apache config or in a virtual host, but for many others you have two good choices; either use an .htaccess file, or place the setting in the vhost (virtual host) configuration. Which one you choose depends largely on your project setup, let’s look at each in turn:

The .htaccess File

The biggest item in favour of an .htaccess file is that it belongs in your webroot, and can be checked in to your version control tool as part of your project. Particularly if your project is going to be installed by multiple people on multiple platforms, this can be a very easy way to get development copies of code set up very quickly and for it to be easy for developers to see what should be in their .htaccess files.

With version control, you can also send new .htaccess configuration through by updating your copy of the file – but whether this is a strength or a weakness is up to you to judge! If everyone needs different path settings, for example, and is constantly overwriting your .htaccess file, that’s not a particularly excellent setup! Previously I’ve distributed a sample .htaccess file with a different file name, and added .htaccess itself to the ignore list of the version control tool.

The Virtual Host

Putting settings in the virtual host allows an easy way to configure the environment on a per-server basis, and not to accidentally deploy an incorrect setup. You could still distribute a sample vhost setup for people to use as their basis, exactly as you could for .htaccess.

The biggest reason for using the virtual host, especially on a production server, is that using .htaccess incurs a performance penalty. When you use .htaccess, apache looks in the current directory for an .htaccess file to use. It also searches in the parent directory … and that parent directory’s parent directory … and so on, up to the root of the file system. Imagine doing that on every request to a system under load!

Which To Choose?

It completely depends. At one end of the system, the open source project that will be set up on a relatively large number of systems by potentially inexperienced people – you’d probably choose .htaccess. For a large-scale, live platform deployment, use the apache settings themselves (a virtual host for a server which runs multiple sites – apache’s own settings for a server which only hosts a single site). Where are you on the scale and which will you choose?