Archive March 2016

PHPUnit compare generated PDF files with Imagick

Sometimes it is necessary to compare a generated PDF file with a given one in PHP. Just to check with one PHPUnit test that your PDF generation works the expected way. But pretty often generated PDF files are equal, but there content isn't the same. For example if you use FPDF the following assertion can fail if the files have different meta data.

$pdfContent1 = file_get_contents('path_to_pdf1');
$pdfContent2 = file_get_contents('path_to_pdf2');
$this->assertSame($pdfContent1, $pdfContent2);

Continue reading

Create a list of dispatched events in Magento2

Magento2 has reduced the use of events. I guess the Magento plug-ins are more powerful. Today I would like to show, how to create a list of all dispatched events after visiting the product page for example. I have written a similar post a few years ago for older Magento versions.

Continue reading

Lesti_Fpc documentation version 1.4.5

Lesti_Fpc is internal full page cache for Magento. This Cache needs no varnish or any other extenal software and works with events. It is an internal cache and so it replaces dynamic blocks before sending response to customer. Here is little post that explains the workflow of Lesti_Fpc.

Continue reading

Magento2 ObjectManager preferences

When developing with Magento2 you have maybe come to the question were is my logger for example. This was the way in Magento before.

Mage::log('Some log message', null, 'file.log');

Maybe you have already found the logger here for example in the class Magento\Backup\Controller\Adminhtml\Index\Rollback.

$this->_objectManager->get('Psr\Log\LoggerInterface')->info($e->getMessage());

Today I don't want to show you the logger. More interesting for me are the shared instances inside of the Objectmanager that you can use with the fucntion get.

Continue reading

Magento2 extension development with Travis CI

If you have started developing a Magento2 shop with Composer you should have noticed that you will need some authentication keys. Alan Kent is explaining in his post Magento 2 and Composer Authentication why Magento thinks this is necessary. It doesn't make much sense to me why it is necessary also to store the open source extensions and modules in a protected repository, but I guess Magento is a control freak.

This protection is really a problem for maintaining open source extensions with Composer in a public continous integration. Today I would like to show how to use Travis CI for open source extensions with the password protected repository repo.magento.com from Magento2.

Continue reading

Magento2 maintenance mode

I use a small Docker image for the development with Magento2. But unfortunately I got a 503 error after every start of the container.

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

The problem was really homemade. My setup script tries to install Magento on every start of the container. But that leads me to the point to take a small look at the maintenance mode of Magento2.

Continue reading