Tags ArchivesPHP

Spawn RabbitMQ consumers with PHP image

Using message queues like RabbitMQ is a nice and easy way to bring PHP processes into the background. Instead of running a time consuming task inside a web request, just push a message to a queue and grab the result later. Sounds easy in the first step. But when it comes to keep PHP processes running in the background to consume those messages on a queue it can get dirty.Running on a dedicated Linux machine will make life easy. But what would you do, if it is not like this. On Linux you can simply use things like supervisord to control it. But what would you do if you have to run in shared hosting (for sure the rabbit must then ...

Continue Reading

Closures are functions with state image

A closure is a programming language concept that combines a function with a reference to an environment during creation time of the function - or simply put: a function combined with some state. But we've heard something similar when people talk about objects in programming languages, haven't we? An object is state combined with functions. So are they interchangeable? Well, up to a certain degree, I'd say, yes. There are use-cases where closures and objects can be used interchangeably and we'll look into one of them.Take a simple example. We have a simple list of employees together with their salary:$list = array( array('name' => 'Blake', 'salary' => 35000), array('name' => 'Sakic', 'salary' => ...

Continue Reading

This is a unique website which will require a more modern browser to work!

Please upgrade today!