·

php

Quickly run scripts in the shell in Magento 2

Magento 2 has a great functionality for running scripts in the command line, but sometimes you just want to quickly check something without creating a new CLI command or creating a unit test. Wouldn’t it be great if you could just write a PHP script and write some simple code in it, just to speed read further ...

Floating point numbers in PHP and your system locale

So the other day I had a strange issue with a certain part on a Magento webshop that I was working on: The checkout wasn’t working. It turned out that there was a parsing error in the JavaScript that stopped the execution of the rest of the script: Needless to say, in the snippet above it’s clear what’s read further ...

Quick Tip : Correctly set the headers of your maintenance page

When you’re deploying updates or migrating entire sites, you probably used a maintenance screen before: a simple screen telling the visitor that there is some major stuff going on on the server and that the site will be back online in a few moments. It’s important that you don’t lose any precious SEO-value of your read further ...

Programatically prefix the img src attribute with a domain name

I just wanted to share this with you guys, because otherwise I might forget it: This is a simple method to prefix the src -attribute of an img -tag with a specific domain name. This method takes HTML like: And prefixes it like this: This is ideal for when you got HTML from WYSIWYG-editors for read further ...

Best practices when it comes to importing CSV files

I often have situations where I – as a web developer – have to link together two different applications. In many cases, this link is created by simply exchanging CSV-documents with an third party. Now when it comes to importing and exporting in PHP (or any other language for that matter) it’s important that you have read further ...

PHP CLI Progress Logger

As some of you might already know, I make great use of the Command Line Interface (CLI) of PHP for tasks or tools that need to be run incidentally or periodically. For tasks that have iterations in them (like while  or foreach -loops) I like to have a visual feedback in my terminal of the progress. For read further ...

Magento unit testing with specific customers

Sometimes you have the situation where you have to write unit tests for Magento that involves Magento customers. If – for example – you have some business logic that depends on certain customer- (or address-) attributes, you want to make sure your code works as expected before you’re deploying it to a live server. Unit testing read further ...

Unit testing Magento with the database

This year I want to dive more into unit testing in PHP. Writing good, test-driven code is important for the stability and guarantee of your project, but it also helps you – as a developer – sleep a little better at night. You might have seen earlier posts regarding unit testing in PHP in the past, read further ...

Prevent the generic ‘Killed’ error in your PHP script

I recently found myself in a task where I had to process 500.000+ rows from a database, each with a while set of columns. The first thing I tried to do was fetch it all in a single query and have PDO sent me a result. My server didn’t like this very much and gave read further ...

1 2