Category Archives: php
Joind.in at PHPNW’s Hackathon
This year will be no exception: PHPNW’s Hackathon is on the Friday evening – you need a conference ticket, and you need to tick the “hackathon ticket” box. Joind.in will be there and we’ve got a very big todo list so if you are looking for something to hack on, then look no further! Continue reading
Compiling PHP Extensions
- The extension isn’t available on pecl (e.g. uprofiler)
- The extension is on pecl, but you need the newest version or a branch with a particular feature or fix in it, perhaps for testing
- You are fixing an extension yourself (yay, we need more people like you!)
Related: If you followed my previous post on compiling PHP, be aware that in the php/bin/
folder there is a pecl binary that will install extensions correctly for whichever version of PHP it belongs to, so you may not need to read the rest of this post. However if you do, the paths follow on from the examples in that post.
I haven’t seen a really approachable guide anywhere, we tend to speak of extensions in hushed tones, and actually it isn’t particularly tricky so here is my quick how-to guide. Continue reading
Running Multiple Versions of PHP
New PHP Videos on OReilly.com
There are two videos available: PHP Web Services and Intermediate PHP (subtitle: a bunch of things Lorna thinks will make developers’ lives and applications better!), you can click through (disclaimer: affiliate links!) to get more information and a detailed chapter outline for each course. I hope that either or both of them will be useful to you. Continue reading
Using Phing with Travis CI
Quickly add Amazon Cloudfront as a CDN
Logging to Stdout with Monolog
I’m a huge fan of Monolog so I grabbed that, but it wasn’t immediately obvious which of the many and varied options I would need for this fairly simple addition. It turns out that the right thing to use is the ErrorLogHandler
, so now my code looks like this:
<?php require "vendor/autoload.php"; $logger = new \Monolog\Logger("log"); $logger->pushHandler(new \Monolog\Handler\ErrorLogHandler()); $logger->addInfo("Something happened");
And the output is neatly in lines like this:
[2014-06-05 17:00:47] log.INFO: Something happened [] []
You can do a lot of different things with Monolog, but since I had to look up this simplest of all options, I thought I’d share.
PHP 5.6 Benchmarks
Recently I ran it again for versions PHP 5.3 through PHP 5.6 and I thought I’d share my results:
Beanstalk, Pheanstalk and Priorities
<?php define("LOW_PRIORITY", 2048); // default is 1024 $queue = new Pheanstalk_Pheanstalk($config['beanstalkd']['host'] . ":" . $config['beanstalkd']['port']); $queue->useTube("scorem")->put(json_encode(array("action" => "my_important_task")), LOW_PRIORITY);
This will add the job to the queue, but anything with a higher priority value (where 1 is the highest priority!) will take precendence. This way I can add as many non-urgent jobs as I want to to the queue without impacting my website performance. My setup has multiple workers and also I tend to write a script that puts loads of tiny jobs on the queue rather than putting one monster task on there. I find this approach a bit more fault-tolerant and also means that incoming tasks can get a chance to get serviced rather than waiting for some crazy huge thing to finish.
I had real issues finding information about the priority settings for beanstalkd and PHP, so hopefully if anyone is looking for it, they will find this post :)