Blog archives

53 posts in the archive

MtMail: e-mail module for ZF2

I'm happy to present a ZF2 module that handles composing and sending e-mail messages.

Why another module? There are a few of them already available on ZF modules website. However, when I was looking for solution to use in my application, I quickly realized that most of them are either outdated, or they miss features I needed. That's why I decided to write my own.

My intention was to create something powerful, but still simple to use. You an customize e-mail headers, add layout, automatically generate plaintext version of HTML e-mail, and so on. But you can also start composing and sending e-emails from your controllers with just a few lines of code.

Using standalone Zend\View

Zend\View is pretty advanced rendering engine, with multiple useful features. It is working nicely within ZF2's MVC stack, where it is automatically configured for you. But how to use it without full MVC?

This can be useful in some situations: when building Your Own Microframework™, when creating an application based on ZF2 components, or (in my case) when working on module that is supposed to render something outside MVC flow. All of this projects can benefit from nested templates, multiple rendering engines, or pluggable architecture of Zend\View.

So, how to do that?

Extracting single table from huge MySQL dump

During last few weeks I had to work with relatively big MySQL dumps. I had to find interesting rows in about 400 files, each of them taking 40 minutes to import. In order to speed things up, I found simple tool that allowed me to extract only interesting tables.

The tool is actually single Perl script, named extract_sql.pl (available on Github). It allows extracting tables with simple command:

[email protected]:~$ extract_sql.pl -t TABLE_NAME -r DUMP_FILE.sql

This command will print dump to console output, so you may want to redirect it to some file:

[email protected]:~$ extract_sql.pl -t TABLE_NAME -r DUMP_FILE.sql > table_name.sql

Finally, extract_sql.pl is able to read input from stdin, so it is easy to extract and import single table from compressed dump file:

[email protected]:~$ zcat DUMP_FILE.sql | extract_sql.pl -t TABLE_NAME \
| mysql dest_database -u username -p

Automated MySQL backup on dedicated server or VPS

I just moved all my small projects to new dedicated server. I have to admit, until now I wasn't paying attention to regular backups. I simply ran mysqldump and copied everything to my laptop every few months. I didn't have any problems with that, as my data was not very critical. But, this time I decided to build something better - I wanted database backups to be generated automatically, at regular intervals.

I knew more or less what to do, I just had to put all pieces together. This tutorial shows necessary steps to build similar solution on your server.

Learning ZF2: Application flow

Zend Framework 2

This post covers basic tasks that you may want to do within controller: forwarding to different actions, redirecting, and displaying 404 page. Once again, I will show how this tasks can be achieved in both ZF1 and ZF2.

Learning ZF2: The Controller

Zend Framework 2

When Zend Framework 2 was officially released, I wanted to learn it on practical example. So, I decided to use it as a foundation for my new blog engine. Because it is very simple application (just a few classes), I was able to build it pretty easily.

This is first post of short series where I will describe how common problems are solved in ZF2. I will always compare it with similar code written in ZF1-style.

First I'm going to describe some common tasks that you usually do in your controllers: handling input parameters and accessing application services.

PHP SDK for CodebaseHQ API

CodebaseHQ

When we started working on Cleeng, we decided to choose CodebaseHQ as our project management and code hosting service. At some point we realised that we could benefit from having a small tool that will automate common tasks like creating topic branches for tickets, marking them as "completed", and so on.

In order to build such tool, I had to create a foundation: small library that can connect to CodebaseHQ API, fetch list of tickets, and post updates. I released it to public - just in case anyone else needed it.

Project is hosted on Github: PHP SDK for CodebaseHQ API

Rzut okiem na Zend Framework 2: Event Manager

Logo ZF2

Zend Framework 2 zbliża się wielkimi krokami. Po okresie zastoju zdecydowano się przenieść główne repozytorium projektu na GitHub i bardziej otworzyć się na społeczność - nie trzeba juz podpisywać CLA przed dodaniem swoich łatek. Dzięki temu rozwój wyraźnie przyspieszył, a kod zaczyna się stabilizować.

Twig w praktyce

Wtyczka do NetBeans kolorująca składnię plików .twig

Jednym z powodów dla którego postanowiłem stworzyć tą stronę własnoręcznie (zamiast sięgnąć po gotowce typu WordPress), była chęć posiadania pewnego rodzaju "poligonu doświadczalnego". Pozwala mi to sprawdzać różne rozwiązania w praktyce, zanim będę mógł "sprzedać je" klientom. Po napisaniu artykułu o Twigu postanowiłem poświęcić trochę czasu i wdrorzyć go na tej stronie. Zadanie okazało się dosyć łatwe i pozwoliło mi zapoznać się z tą technologią.
W tym poście zebrałem kilka przykładów i porównań między szablonami w czystym PHP a Twigiem. 

Zend Framework i Twig - integracja

Wtyczka do NetBeans kolorująca składnię plików .twig

PHPpowe systemy szablonów są teraz na topie: są szybsze i znacznie potężniejsze od swoich pierwowzorów sprzed kilku lat. Może już czas odejść od widoków tworzonych w czystym PHP?

Nie chcę wylewać własnych przemyśleń na temat wad i zalet różnych "szablonowych" rozwiązań. Przedstawiam gotowy przepis, jak zmusić Zenda do współpracy z systemem Twig. Dlaczego Twig? Opiekunem projektu jest Fabien Potencier - współautor Symfony, postać, której w światku PHP nie trzeba nikomu przedstawiać. Nazwisko to gwarantuje otrzymanie przemyślanego, wygodnego w użyciu i dobrze przetestowanego kodu.