Ripeworks

Using Composer Globally

Package managers are great. One of the great things about npm -g or gem is the ability to expose bin scripts to provide utilities for developers.

In Composer, currently there is no support for this.

I wrote a little script that will set up a Composer location to be used globally. It's super easy to use:

$ curl https://gist.github.com/tamagokun/4242494/raw/3325cac939660ca2e7962185cfb42ee4f361b83e/global_composer.sh | sh
Sweet.
Be sure to add $HOME/.composer/bin to your PATH

Require a package:

$ cd ~/.composer && composer require package-name:version

Here is the script source:

Run Wordpress Locally Using PHP's Built-In Web Server

Getting up and running for PHP development can be a rather pain in the butt sometimes. Possibly the biggest culprit being the web server that needs to handle requests. Even after everything is working properly you are still mucking with virtual hosts, etc. Finally, it doesn't have to be this way!

PHP 5.4 Built-in Server

PHP 5.4 introduced a much needed feature. The ability to run a basic web server for development purposes via the command line. It goes like this:

$ php -S localhost:port

You can pass an optional script path which will act as a router and all requests will pass through this script before continuing. This allows you to manipulate the request before it gets sent to your application.

Installing PHP 5.4

Mac OSX doesn't come pre-installed with PHP 5.4, so you'll have to manage installing it before you can do this. One of the following methods will definitely work for you:

  • via Homebrew sh $ brew tap josegonzalez/homebrew-php $ brew install php54
  • via php-osx
  • via php-build

Make sure you properly adjust your $PATH accordingly.

Getting Wordpress to use it

Below is a router that will allow you to fire-up a Wordpress installation using this built-in development server.

Drop this script in your project, and off you go!

$ php -S localhost:9393 -t /path/to/wordpress router.php

If you placed router.php inside your wordpress directory, don't bother with the -t flag. That is to specify an alternative document root.

A Slow Move To Cloud Stuff

Since 2008 I have been happily using Slicehost for my virtual server needs. At the time, they were cheap and they have great appeal for developer types. Specifically, you can create a slice with a vanilla install of your linux of choice. This is pretty standard nowadays, but back then you were typically overloaded with Plesk and all sorts of junk.

Recently I have been trying to revamp bills and things like that, and decided it was time to take a look at how much I am spending per month on hosting, and to see if I could reduce that cost at all.

View Archives