·

php

Converting multiple MySQL INSERTS into a single statement

So I had to import this huge MySQL database the other time and I had the problem that each INSERT -statement only contained 1 row of data. Now, for a small database this is not a big deal, but for a database that’s 1GB or more importing all these separate rows takes forever! So i had read further ...

Split content with a horizontal rule

Today I want to share a little technique with you that I use for much of my clients. There are many times when you need the content to be split in two in the frontend. Think about a custom wrapped header, a text in 2 columns, an introduction, etc. In my opinion the client must read further ...

htmlspecialchars(): Invalid multibyte sequence in Magento

So if you use the $this->escapeHtml() -method in a template in Magento, you might have come across an error something like this: The problem here is a bug in older PHP versions where the combination of display_errors=off  and multibyte string throws this error (yeah that’s right…). The fix is rather simple. Instead of directly passing your value read further ...

How to write unit testable code

We all know the importance of unit testing. But to write unit testable code requires a different kind of thinking. Take this method for example: it’s a simple method that executes a SQL query: Now you could imagine that to test this code it requires setting up some actions to do before running your test read further ...

Magento different caching on different PHP versions

Today I tested some different configurations for Magento to see if I could boost the performance. One major aspect of this is which caching to use (internal, memcached, APC or OpCode) in combination with different PHP versions (5.3, 5.4 and 5.5). The differences in these tests are big, but is the fastest solution also the best read further ...

How to keep your WordPress theme clean

More than once when I look at WordPress themes I see a lot of disorganised code. This varies from functions.php -files with hundreds lines of code that are a mixture user-specified functions and WordPress-specific functions (add_filter() , add_action() , etc). Also the templates files themselves are more often a complete mixture of HTML and massive blocks of PHP-code. Even read further ...

Poor mans’ multithreading in PHP

I’m currently writing an application in which multiple requests are send out to multiple servers. I do this with a CLI script I wrote in PHP (since that’s the language I’m most familiar with). I wrote a simple foreach() -loop in which I made my requests to the server, analysed the response and logged them. Now, the read further ...

Setup PHP CodeSniffer for PHPStorm on OSX

On Meet Magento 2014  I attended an interesting presentation about Continues Integration in Magento from Damian Luszczymak. One important aspect of Continuous Integration is that as a team of developers everyone should follow the same coding guidelines. If you use PHPStorm, you can use PHP CodeSniffer to ensure that the code you are writing as a team is read further ...

How to install XDebug on OSX

As a follow-up on my previous post, this post explains how you can easily install XDebug on your OSX webdevelopment configuration, making your life as a developer a whole lot easier.read further ...

1 2