Événement — PHP Event Dispatcher

Événement is a very simple event dispatching library for PHP. It has the same design goals as Silex and Pimple, to empower the user while staying concise and simple. Concise indeed. At the core it’s a tad above 50 lines of codes. Listening for events: $emitter->on(‘user.created’, function (User $user) use ($logger) { $logger->log(sprintf(“User ‘%s’ was …

Silex $app['autoloader']->registerNamespace() deprecated

The past few days I’ve been playing around with Silex, a micro PHP Framework. At a certain point I got stuck in the process when using a custom controller: the darn class just wouldn’t load and the (otherwise excellent) documentation on the Silex site has not mention on how to load it. Most of the …

PHP TokenPhrase Generator

Based up on this TokenPhrase Ruby Gem I decided to quickly write a PHP variant of it. With it, one can generate unique phrases for you to use in your app as tokens. <?php require_once __DIR__ . ‘/../src/autoload.php’; for ($i = 0; $i < 10; $i++) { echo TokenPhrase\TokenPhrase::generate() . PHP_EOL; } The resulting output …

Composer – Dependency Manager for PHP

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. Think npm install but then for PHP { “require”: { “monolog/monolog”: “1.2.*” } } $ composer install Plays nice with packages that support PSR-0 autoloading. …

Guzzle — PHP HTTP Client

Guzzle is a framework that includes the tools needed to create a robust web service client, including: Service descriptions for defining the inputs and outputs of an API, resource iterators for traversing paginated resources, batching for sending a large number of requests as efficiently as possible. <?php require_once ‘vendor/autoload.php’; use Guzzle\Http\Client; // Create a client …

PHP 5.5.0 alpha 1

PHP 5.5.0 alpha 1 was released a few days ago. New features include: support for Generators, a new password hashing API, support for finally in try/catch blocks, support for list() in foreach, constant array/string dereferencing, ext/intl improvement More info on these features can be read in Test Drive PHP 5.5: A Sneak Peek and What …

Geocoder — The almost missing Geocoder PHP 5.3 library.

Uses FreeGeoIp, HostIp, IpInfoDB, Yahoo! PlaceFinder, Google Maps, Bing Maps, OpenStreetMaps, Geoip, and CloudMade geocoding services to geocode addresses and IP Addresses. <?php // Create an adapter $adapter = new \Geocoder\HttpAdapter\BuzzHttpAdapter(); // Create a Geocoder object and pass it your adapter $geocoder = new \Geocoder\Geocoder(); // Then, register all providers your want $geocoder->registerProviders(array( new \Geocoder\Provider\YahooProvider( …

React: Event-driven, non-blocking I/O with PHP

Inspired upon Node.js: <?php require ‘vendor/autoload.php’; $stack = new React\Espresso\Stack(function ($request, $response) { $response->writeHead(200, array(‘Content-Type’ => ‘text/plain’)); $response->end(‘Hello World\n’); }); echo ‘Server running at http://127.0.0.1:1337’ . PHP_EOL; $stack->listen(1337); React →