PHP Icon


PHP is a scripting language that works particularly well for server-side web development.
42 Stories
All Topics


A high-performance PHP app server, load balancer, and process manager

RoadRunner is an open source (MIT licensed), high-performance PHP application server, load balancer and process manager. It supports running as a service with the ability to extend its functionality on a per-project basis.

RoadRunner is written in Go, and can be used to replace the class Nginx+FPM setup, boasting “much greater performance”. I’d love to see some benchmarks. Better yet, I’d love to see someone use this in production for a bit and write up their experience.


Generate 4 language bindings for your API in one Go

You just built an API, and want to make sure everyone can use it. Building libraries in every language isn’t only going to be hard, its going to take a lot of time. Time you don’t have. This is where Alpaca can help.

You define your API according to the format, alpaca builds the API libraries along with their documentation. All you have to do is publishing them to their respective package managers.

Right now it can generate API clients in PHP, Python, Ruby, and JavaScript. You can see examples of the generated client libraries here. I can’t speak to the quality of all the generated language bindings, but I took a cursory look at the Python lib and it looks good. Looks like Alpaca could save us all a lot of time.


PredictionIO, a machine learning server for software developers and data engineers.

Want to add personalization such as recommendations or content discovery to your application? PredictionIO has your back.

You can download and install the server yourself or use their cloud infrastructure. Clients already exist for Java, PHP, Python, and Ruby, and I assume more are on the way.

Check out all of their open source goods right here.


Meet Boris, a tiny REPL for PHP

Chris Corbyn was frustrated with PHP’s lack of a good REPL, so he took matters into his own hands and created Boris. I can relate to Chris’s experience. Back when I used to write WordPress plugins I got so frustrated by the lack of a Rails-like interactive console that I created one for WordPress.

Boris is cooler than my little plugin because it works outside of WordPress and runs directly in your terminal. Check it out in action:

You can install Boris via Packagist or use it directly by cloning the repo:

git clone git://
cd boris

This and much more information about the REPL is available in the README. Boris is MIT licensed and hosted on GitHub.


Bring your server side debug logging into the browser with Chrome Logger

If you find yourself jumping back and forth between Chrome’s Dev Tools and a terminal displaying your server side request logs, Craig Campbell’s Chrome Logger might be just the thing you need!

It’s a Chrome extension which lets you see your server side logs right in the browser. There are currently libraries for:

Is your server side language/environment of choice not on that list? Don’t worry, Chrome Logger uses an open and published protocol so you can easily write client libraries of your own!

See the project’s home page for more info or check under the hood if you’re curious about how it all works.


Requests - HTTP library for PHP

Higher level libraries for dealing with HTTP are cropping up in almost every language. The latest is Requests, a PHP library from Ryan McCue. Inspired by Kenneth’s Python library of the same name, Requests aims to provide a better HTTP API than cURL:

$headers = array('Accept' => 'application/json');
$options = array('auth' => array('user', 'pass'));
$request = Requests::get('', $headers, $options);

// int(200)

// string(31) "application/json; charset=utf-8"

// string(26891) "[...]"

I’ve written about my thoughts on what makes a good API wrapper and libraries like these that provide a more idiomatic experience are just great.

Grab Requests on GitHub.


Imagine - Unified PHP 5.3 API for GD2, ImageMagick, GraphicsMagick

Imagine is a nice looking image manipulation library for PHP 5.3+ that supports GD2, ImageMagick, and GraphicsMagick in a clean, chainable API from Bulat Shakirzyanov:


$imagine = new ImagineGdImagine();
// or
$imagine = new ImagineImagickImagine();
// or
$imagine = new ImagineGmagickImagine();

$size    = new ImagineImageBox(40, 40);

$mode    = ImagineImageImageInterface::THUMBNAIL_INSET;
// or
$mode    = ImagineImageImageInterface::THUMBNAIL_OUTBOUND;

    ->thumbnail($size, $mode)

Check out the extremely detailed project docs and examples for advanced usage.


Options-Framework: Expose an options panel for your Thematic WordPress themes

I don’t always use WordPress, but when I do, I prefer Thematic (and compass-wordpress). Thematic is a WordPress theme framework from Ian Stewart that provides an abstracted API, letting you focus on your site instead of the lower-level minutia of WordPress.

I was excited when I stumbled across a couple of projects by Devin Price that let you easily expose an options panel for your theme. Thematic Options (and the non-Thematic Options Framework) make it easy to add an options panel for your theme settings, letting your end users customize your theme in the WordPress admin panel.


Options are declared in a PHP array, as in this example:

// Set the Options Array
global $my_options;
$my_options = array();

$my_options[] = array( "name" => "General Settings",
                    "type" => "heading");

$my_options[] = array( "name" => "Custom Logo",
          "desc" => "Upload a logo for your theme, or specify the image address of your online logo. (",
          "id" => "logo",
          "std" => "",
          "type" => "upload");

$url =  ADMIN . 'images/';
$my_options[] = array( "name" => "Main Layout",
          "desc" => "Select main content and sidebar alignment. Choose between 1, 2 or 3 column layout.",
          "id" => "layout",
          "std" => "2c-l-fixed.css",
          "type" => "images",
          "options" => array(
            '1col-fixed.css' => $url . '1col.png',
            '2c-r-fixed.css' => $url . '2cr.png',
            '2c-l-fixed.css' => $url . '2cl.png',
            '3c-fixed.css' => $url . '3cm.png',
            '3c-r-fixed.css' => $url . '3cr.png')
$my_options[] = array( "name" => "Custom Favicon",
          "desc" => "Upload a 16px x 16px Png/Gif image that will represent your website's favicon.",
          "id" => "custom_favicon",
          "std" => "",
          "type" => "upload"); 

$my_options[] = array( "name" => "Tracking Code",
          "desc" => "Paste your Google Analytics (or other) tracking code here. This will be added into the footer template of your theme.",
          "id" => "google_analytics",
          "std" => "",
          "type" => "textarea");


Devin has a nice blog post with more info including how to use these values in your theme, along with an introductory screencast.

[Source on GitHub]


Respect, Validation for PHP developers

Are you a PHP developer who feels like you get no respect? That’s exactly what Alexandre Gomes Gaigalas and Carlos A. Ferrari are offering with their GitHub organization.

Validation is billed as “the most awesome validation engine ever created for PHP.” While that might be the epitome of hyperbole, it is indeed nifty. Validation includes more than 30 chainable validators supporting composite validation of nested, grouped, and related rules.

Let’s look at a simple example:

use RespectValidationValidator as v;
v::numeric()->validate($someNumber); //returns true or false 

We did mention chaning, right?

//From 1 to 15 non-whitespace alphanumeric characters 
$username = 'alganet';
$validUsername = v::alnum()

Validators are also reusable:

$idValidator = v::int()->positive();
$idValidator->validate(123); //true
$idValidator->validate(456); //true

Be sure and check the Readme for advanced usage. Also be sure and check out Respect’s other projects including:

  • Relational is a chainable abstraction for relational database queries
  • Daemon is a library for managing daemon systems using PHP
  • Stream is a lightweight, asynchronous, object-oriented layer for the great PHP stream API
  • Env is a lightweight, transparent, testable and awesome environment wrapper for PHP

[Source on GitHub]


GitHub Follow Friday for 20101029

Another Friday, time to spotlight some GitHub folks you should follow.

tenderlove (Aaron Patterson)

The author of nokogiri and mechanize, Aaron also empowers you to do fuzzy texticle searches.

isaacs (Isaac Z. Schlueter)

The man who helps you manage your package using npm.

abraham (Abraham Williams)

The author of the canonical PHP library for the Twitter API and fun Chrome extensions, a cool dude who is master of his domain — name.


modernizr-server: Modernizr on the server-side

James is a technologist, executive & entrepreneur, working in the arena of the mobile web, all while living around the world. This year he happens to be living on an island off Belize.

He also wrote modernizr-server - a way to bring Modernizr browser data to your server scripting environment. PHP is currently supported, and James intends to offer other server-side environments in the future, but that’s going to be based on demand!

We’ve covered Modernizr being used in other projects before. Modernizr is a great way to find out about your user’s browser capabilities. However, you can only access its API on the browser itself, which means you can’t easily benefit from knowing about browser capabilities in your server logic.

Progressive enhancement, media queries and body classes are fine for tweaking sites and their appearance. But for structural changes to sites and pages, sometimes it’s much simpler to just emit the right markup from the server in the first place.

The modernizr-server library is a way to bring Modernizr browser data to your server scripting environment. For example, in PHP:



    print 'The server knows:';
    foreach($modernizr as $feature=>$value) {
        print "<br/> $feature: "; print_r($value);


The server knows:
canvas: 1
canvastext: 1
geolocation: 1
crosswindowmessaging: 1
websqldatabase: 1
indexeddb: 0
hashchange: 1

How it works

The first time the user accesses a page which includes the modernizr-server.php library, the library sends the Modernizr script to the client, with a small script added to the end. Modernizr runs as usual and populates the feature test results.

The small suffix script then serializes the results into a concise cookie, which is set on the client using Javascript. It then refreshes the page immediately.

This second time the PHP script is executed, the library takes the cookie and instantiates the server-side $modernizr object with its contents. If possible, this is placed in the PHP $_SESSION so that it can be quickly accessed in subsequent requests.

While either of the cookie or session remain active, no further execution of the Modernizr script will take place. If they both expire, the next request to a page containing modernizr-server.php will cause the browser to rerun the Modernizr tests again.

And also …

You might also want to read James’ blog post on Modernizr on the server-side.

Check out the codes

[Source on GitHub] & [Documentation]


WatchWednesday for 20100929

It’s Wednesday again, time for us to serve up another quick list of projects to watch on GitHub. These are projects you might have missed or should could keep an eye on.


David Dollar makes automatically scaling your Heroku dynos a snap with this gem. Simply add the gem to your Gemfile

gem 'heroku-autoscale'

and configure your Heroku credentials and the minimum and maximum numbers of dynos for your app in your rackup file

use Heroku::Autoscale,
  :username  => ENV["HEROKU_USERNAME"],
  :password  => ENV["HEROKU_PASSWORD"],
  :app_name  => ENV["HEROKU_APP_NAME"],
  :min_dynos => 2,
  :max_dynos => 5,
  :queue_wait_low  => 100,  # milliseconds
  :queue_wait_high => 5000, # milliseconds
  :min_frequency   => 10    # seconds

Now your app will scale up with traffic and down as traffic wanes.


Warning! This email address will self destruct. Perfect for media site content walls, contests, or auction transactions, Tempalias is powered by Node.js and lets you create email addresses with a built-in expiration using or hosted on own your own site.’s Apple Push Notification Service gem

Send and read Apple Push Notifications from Ruby:

Jtv-apns is a gem for accessing the Apple Push Notification Service that allows both sending notifications and reading from apple’s feedback service. This gem is based heavily on the work of James Pozdena.


Tweetnest is a PHP app to archive, browse, and search your tweets.



A nice Git wrapper for Vim:

View any blob, tree, commit, or tag in the repository with :Gedit (and :Gsplit, :Gvsplit, :Gtabedit, …). Edit a file in the index and write to it to stage the changes. Use :Gdiff to bring up the staged version of the file side by side with the working tree version and use Vim’s diff handling capabilities to stage a subset of the file’s changes.

0:00 / 0:00