composer more.json

July 17th, 2013

So tonight, more fun with composer. Now that I have it set up and managed to install one package, it’s on to getting enough of Zend Framework set up to make something. Since there seems to be no core package that just installs everything, it seems I have to resort to listing the arms length of packages I expect to use.

Scratch that. Tonight I’m going to try out the ZF2 skeleton application, since I haven’t used ZF2 yet.

Python Isn’t Just A Snake

July 16th, 2013

And I’m going to learn it.

composer pain.json

July 15th, 2013

So tonight I decided to try and use Composer, a “dependency management” tool for PHP. I’ve had my eye on doing this for a while, and finally got to it tonight.

I use a custom rolled version of PHP 5.5, because I want to actually use the new functionality that PHP has finally added. So, on to the install I went.

curl -sS | php

Already, the first critique here, I’m downloading a file and piping it right on into PHP. I’m not going to go into that, because this guy already has. So, on to the next step, after I took a quick poke through the installer code I downloaded.

Woops, need to recompile my PHP binary without --disable-phar. Now, done that, I ran the installer again, and had a clean install this time.

Next step, create a composer.json file after running through the Composer install steps. I wanted to use Zend Framework, so I copied the snippets of composer JSON from this site and assembled them into a coherent composer file (not the easiest thing, since the Composer manual didn’t seem to have a nice example file linked somewhere that I could find).

My basic composer.json file:
"repositories": [
"type": "composer",
"url": ""
"require": {
"zendframework/zend-config": "2.*"

Next, ran a composer validate composer.json on my file, and got this output:
composer.json is valid for simple usage with composer but has strict errors that make it unable to be published as a package:
See for details on the schema
name : is missing and it is required
description : is missing and it is required
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.

After a quick look over the messages, I decided to soldier on anyway, crossed my fingers, and ran composer install.

The installer seemed to laugh at me after it downloaded the files, and told me that I needed to --enable-zip before I could install the packages. THANK YOU COMPOSER, for mentioning that on install.

Another recompile, and finally I managed to get Composer to behave.

Lessons Learned

  • Composer needs both PHAR and Zip enabled to work, but doesn’t like to mention those things
  • Custom PHP is fun to do, but can be a pain when you need to turn things on that you didn’t plan on using

Globally Scoped

July 14th, 2013

Global variables are a code smell. This statement is both true and false. What is true is that they are a problem when they are no longer the right variables to be global.

Today I had to re-factor a function to be able to use multiple servers inside one script instance. Initially, the server connection was created and stored in one variable that was then referenced. This worked well, because the code that called this function didn’t have to worry about what server connection was involved.

Of course, the problem started when I added a second server into the mix. Now, this function had to be able to access either server, selected by the code in some of the places that called it. The easiest way to solve this would have been to keep the global and add a second optional parameter to override it, but that would not be as clean a fix as just fixing the global.

And so I re-factored the function call to pass in the server connection to use. This makes the function more flexible, because I can add new servers to the mix and just pass in the variable for the one I want to use. The other benefit is that in eliminating the global, this function is now finally completely self-contained, making it that much easier to test and fix.

Lesson Learned
Globals can be useful, but will make it harder to properly test a function, and complicates matters if the function that uses them is widely used and has to be changed.

Choose carefully how to use them.

Problem Solving

July 13th, 2013

Yesterday’s lesson was that the better solution to a problem usually only becomes obvious when you’re almost done solving the problem.

WordPress - Entries (RSS) and Comments (RSS) - © 2011 Ben Dauphinee