Conflict error on PECL YAML

If you are trying to install PECL YAML on Mac OS X Lion, you may find you get a conflict with an error message similar to the following.

WARNING: conflicting files found:
yaml/LICENSE (

This error is documented on GitHub and as it is not critical, can be overcome by turning off errors.

pecl install --ignore-errors yaml

On running that command, it should no longer stop at that point.

PHP complains date.timezone is not set

Sometimes, PHP will kick up a fuss complaining about date.timezone not being set. We found this on the Symfony framework and were able to replicate it on standalone scripts.

DateTime::__construct(): It is not safe to rely on the system's timezone settings.
You are required to use the date.timezone setting or the date_default_timezone_set()
function. In case you used any of those methods and you are still getting this
warning, you most likely misspelled the timezone identifier.
We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead

Normally, you would fix this by editing your php.ini file and adding a declaration there.

date.timezone = "Europe/Berlin"

But we had already done this and it still wasn’t working! After some further investigation, it seemed that PHP simply couldn’t access the value.


This doesn’t make any sense, and we never got to the bottom of what was going on, but there are two ways around the problem. Firstly, you could modify your PHP script so that it makes a call to set the system timezone.


However, this involves having to modify your code, which is bad as you don’t want to have to set the timezone manually, especially in a piece of code which could be deployed to servers in different timezones.

A better approach is to set it in the vhosts directive in Apache.

php_value "date.timezone" "Europe/Berlin"

This isn’t the cleanest solution but allowed us to solve an otherwise unexplainable error.

Missing psych (for YAML output)

If you’re using YAML in Ruby and have it installed via RVM, you might get a notice similar to the following.

It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

You can solve this using the following commands.

rvm pkg install libyaml
rvm reinstall 1.9.3

You may (or even need) to replace 1.9.3 with your exact version number.

PHPUnit on OSX Lion CLI

If you’re trying to run PHPUnit from the terminal in Mac OSX Lion, you may get an error similar to the following.

File/Iterator/Autoload.php failed to open stream

You can resolve this by running the following commands.

curl > go-pear.php
sudo php -q go-pear.php

PHPUnit should now run without errors (or at least, without errors in their code 😉 ).

Cassandra RubyGem on Mac OSX Lion

If you’re trying to run Apache Cassandra with the RubyGem, you may encounter an error similar to the following.

thrift_client(0.8.1 not ~> 0.7.0)

You can fix this by editing the RubyGem.

cd /Library/Ruby/Gems/1.8/gems/cassandra-0.12.1/lib/
vim cassandra.rb

Find the line which sets the dependency.

gem 'thrift_client', '~> 0.7.0'

Change it to the following.

gem 'thrift_client', '~> 0.8.0'

Your script should now run without an error.

Install Memcache on CentOS 6 cPanel

Here is how to install Memcache for PHP on a CentOS 6 cPanel / WHM box. Some of the guides suggest that you need libevent (well, you do need libevent), though when I tried it, I already had it installed. But if you need it, yum will sort you out.

yum install libevent

Next, install memcache itself. Note that the package is called memcached.

yum install memcached

Of course, just installing it doesn’t mean that the daemon is running. So don’t forget to start it too!

/etc/init.d/memcached start

Finally, we need to add the PHP extension. Beware that the PECL installer on WHM won’t work! So you need to compile it manually from source. That isn’t too difficult though.

tar zxvf memcache
cd memcache-3.0.6
make install

And add the extension to your php.ini.

Now restart Apache and a memcache section should appear in your PHP info.

ActiveRecord::ConnectionNotEstablished in Rails

I ran into this error while trying to get Ruby on Rails 3.1.1 which I installed from the Rails Installer to talk to MySQL. My stack is built from WAMP, so it might not have been as easily as it would be on a standlone MySQL installation.

Here is are the steps I took to fix it.

Edit Gemfile in project and add the following line.

gem 'mysql2', '< 0.3'

Rebuild the MySQL adapter with your version of MySQL.

gem uninstall mysql2
gem install mysql2 -- --with-mysql-config="C:/wamp/bin/mysql/mysql5.5.16/bin/"

Download the MySQL connector from the MySQL website.

Once you have the zip file, uncompress it and copy lib/libmysql.dll to the Ruby bin directory. Finally, go back to your Rails project and run the following command.

bundle install

I was finally then able to run a command such as the following.

rails generate model Something name:string

Without it throwing any errors up.

PHPUnit and PEAR packages break on Mountain Lion

If you have recently upgraded to Mac OS X Mountain Lion (10.8) you may find that PHPUnit and other PEAR packages no longer work. You may get errors similar to the following.

PHP Copy & Paste Detector

Warning: require(PHPCPD/Autoload.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpcpd on line 49

Fatal error: require(): Failed opening required 'PHPCPD/Autoload.php' (include_path='.:') in /Users/chris/pear/bin/phpcpd on line 49

PHP Mess Detector

Warning: require_once(PHP/PMD/TextUI/Command.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpmd on line 38

Fatal error: require_once(): Failed opening required 'PHP/PMD/TextUI/Command.php' (include_path='.:') in /Users/chris/pear/bin/phpmd on line 38

Unfortunately, there doesn’t seem to be an easy way to fix them, other then by reinstalling each package.

sudo pear install --force --alldeps phpunit/phpunit
sudo pear install --force --alldeps phpmd/PHP_PMD

The tools should then run as expected.