Roger Stringer   About ▾

I'm Roger Stringer: a father, writer, developer, consultant, chef, speaker. Founder of TheInterviewr.

How to rewrite urls with PHP 5.4’s built-in web server


With the release of PHP 5.4, we were given a handy built-in web server. This server is obviously not suitable to use in production environments, but it is great if we want to check on one project quickly:

  • git clone from github
  • composer install to install dependencies
  • run the built-in web server and test the application.
php -S localhost:8888

But it’s also common to use mod_rewrite or similar to send all requests to a master controller. Usually, we’d have a setup like this:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]

But PHP’s built-in web server doesn’t handle mod_rewrite, and when it came to working on projects, I needed a way to make this work for development. So I came up with this solution of creating one router file and then start the server with it:

And now we start the server with:

php -S localhost:8888 routing.php

All processes are directed through routing.php which then redirects all non-CSS, JS or image requests to index.php and from there the rest is history.

Handy right?

Filed Under: Code


Growing up Okanagan



I live in the Okanagan valley in British Columbia, more specifically in Penticton.

This area is interesting as we are surrounded by mountains on two sides and lakes on the other sides. The end result is most kids grow up skiing in the winter, and hitting the lake in the summer. We have Lake Okanagan on one side, and Skaha Lake on the other side, both with sandy beaches that are groomed daily.

The picture above is my daughter, as she suits up to spend a day out on the lake on her body board, her new favourite summer hobby, along with a dozen or so other kids all doing the same thing.

Filed Under: Images


Fish Cakes


I’m originally from Newfoundland, and fish cakes are a staple we grew up with alongside another traditional dish called fish and brews.

You can actually make this with just about any type of fish, but I prefer to use Cod, or Sole, as white fish tends to take on the flavours you cook it with.

What you need

  • 1 ½ pounds salt dried cod
  • ¼ cup butter
  • 1 small chopped onion
  • 6 cups mashed potato
  • 1 beaten egg
  • 2 tbsp dried savoury (optional)
  • 1/2 tsp black pepper
  • 1/2 tsp paprika
  • 1/2 tsp garlic powder

How to make it

  1. Simmer the cod in boiling water for about 15 minutes.
  2. Drain the water off the fish and allow the fish to cool to almost room temperature.
  3. When the fish is cool, flake it apart with a fork into small pieces.
  4. In a sauté pan, melt the butter over medium heat.
  5. Add the onions and cook until they are softened.
  6. Add the flaked fish along with the mashed potato, egg, pepper, paprika, garlic and savoury.
  7. Mix together until well combined, then form into small cakes and roll in flour.
  8. Fry the fish cakes in canola oil over medium heat until golden brown on both sides.

This is a traditional way to make it, you can also add a little hot sauce into the mixture for flavour if you wanted to.

Filed Under: Food