How to setup Docker container with legacy PHP 5.6 and Xdebug

PHP 5.6 is currently outdated and no more supported, but sometimes, in real World, you could be forced to setup and debug legacy projects that works with outdated technologies. I had to. And I always use Docker for this, of course. But I also need to use Xdebug in order to debug those legacy projects, and common Xdebug installation procedures don’t work with outdated PHP. If fact, if you try, you will get back something like this: [Read More]

Split, reduce and convert PDF to JPEG using PHP ImageMagick

During these days I’m working on a PHP project based on manipulation of PDF files uploaded by users. Documents must be truncated, splitted to images, quality reducted, etc. Because of the project’s nature, libraries' inclusion is problematic, so I was forced to study a solution for the issue that involves only PHP official extensions. The result is some code based on ImageMagick extension. In this post I’ll note down what I found because I hope that it can be useful for someone in my own situation. [Read More]

Quickly setup HTTPS on PHP Apache2 Docker container with self-signed SSL certificate

I often use local Docker images for development reasons, and sometimes, I need to implement features that only works in HTTPS environment: i.e. JWT Bearer token. So, I prepared a Docker container based on official PHP Apache2 Docker container, that quickly setup HTTPS environment with a self-signed certificate. Follows a starting docker-compose structure that you can be extended as needed. It contains only 2 files: docker-compose.yml apache2/Dockerfile Let’s see file content. [Read More]
Docker  PHP  SSL  HTTPS 

Building ZF3 composed pages using Nesting View Models and Forward Controller Plugin

Normally in ZF3 MVC projects, each controller action matches one view and use it to render its output. Occasionally, we may want to build your ZF3 pages by dispatching various controllers from within the matched controller and merging outputs into a unique final view. In this way we can aggregate one or more views to create complex pages like report summaries or widget dashboards. In this post, we will see how to write few lines of code to include output of an arbitrary action into action matched from route. [Read More]

How to inject Zend Service Manager in ZF3 Controllers

Zend Service Manager component is Zend Framework’s implementation of service locator pattern. This object is very usefull component for an application and is largely used in ZF applications. Unfortunately in ZF3 default application, Service Manager component is no more available in controllers. An official solution exsists for this, but in this little tutorial, I want to share an easy solution to inject Service Manager in all controllers. To implement this solution, we will write our controllers by extending an abstract controller class written to handle a Service Manager instance. [Read More]

How to setup a Translate Controller Plugin in Zend Framework 3

Sometimes in our Zend Framework 3 multi-language application, we could need to access to Zend Translator component directly from Controllers. For example, when we have to translate a string to return in a JsonModel. So, let’s see how to write a very simple Controller Plugin that will help us to save a lot of code (and time). Following explanation will assume we just have at least a Skeleton ZF3 Application with working Zend Translator component. [Read More]

Update Twitter Bootstrap to release 3 in Zend Framework 2

Recently I started a new project based on Zend Framework 2, using Twitter Bootstrap as CSS framework. Some days ago, new Bootstrap v3 was released and introduced a lot of changes and improvements. Because of ZF2 Skeleton Application comes out-of-box with Twitter Bootstap 2, I decided to setup the new project skeleton and update CSS framework to latest available release. In this post, I’ll describe the process to update Bootstrap to v3 into a ZF2 project. [Read More]

PHP jobs with Gearman and Supervisor

The problem Often in a PHP project there could be operations that need to be executed asynchronously. Some example are: processing mail queues, indexing data, computation that requires long elaboration time. A common behavior is handle those operations by using cron to execute processes in background. However, using cron requires expedients to avoid cross executions and forces us to implement some specific procedures and mechanism to store data needed to elaborate. [Read More]
PHP 

Processi PHP con Gearman e Supervisor

Problema Spesso in un progetto PHP capita di dover eseguire operazioni in modo asincrono. Alcuni esempi sono: lavorazione di code email, indicizzazione di dati, calcoli che richiedono lunghi tempi di elaborazione. Prassi comune è gestire tali operazioni utilizzando cron per eseguire processi in backgroud. Tuttavia, utilizzare cron richiede espedienti per evitare l’accavallemento delle esecuzioni e ci costringe ad implementare procedure specifiche e meccanismi di stoccaggio dei dati necessari per l’elaborazione. [Read More]
PHP 

Zend Framework 3.0 branch started!

Yesterday, Evan Coury, Zend Framework contibutor, announced start of Zend Framework branch. Development goals will be merged between ZF team ideas and community suggestions that will be collected in this topic. Anyway, Evan immediatly specifies that development will be focused on avoid dramatic migration as was for transition from ZF1 to ZF2. For all developers that use Zend Framework for their projects, this is the best opportunity to take part to development process and be heard about their needs: power of Open Source. [Read More]