Category: php

  • PHP psalm annotations

    random psalm phpdoc things i keep forgotting

  • Hello (again) world

    I don’t blog very often. I should probably stop bothering with the automated twitter compilations. In other news, some legacy PHP code I look after had this : Yes, that’s including a file name that starts with a ‘#’ … which while it’s a clever idea, it’s also a pain in the bum to edit…

  • PHP Generators – an example

    I’ve ignored generators for sometime in PHP, but recently realised why they can be quite handy 🙂 As an example, imagine you are querying a web service, which returns  data in chunks of up to 100 results….

  • Mockery (test doubles/mocking dependencies)

    [This is a relatively old post I think I forgot to publish….] Previously, I’d only used PHPUnit’s mock implementation; however lately I’ve been exposed to Mockery. While they both achieve broadly the same result (at least from my point of view), here’s an example of how to mock dependencies with Mockery. Class to test: class…

  • Random wordpress malware

    A customer’s server was compromised ages ago with lots of lots of WordPress malware. The developers are now on top of it, thanks to a combination of : * Removing wordpress’s write permission (moving over to just use SFTP) * Adding maldet (Linux Malware Detection). * Tightening up the firewall so only incoming connections to…

  • dotdeb – apt package pinning

    As of last night, Debian Security released PHP 5.4.44 for Wheezy. Wheezy shipped with PHP 5.4.12 or something like that. DotDeb is currently on 5.4.43, and if you’ve been using it based on the assumption that it has a newer version of a package over Debian, then an upgrade will leave your PHP install in…

  • PHP 5.4 + xcache -> PHP 5.6 + Zend OpCache memory usage

    In relatively unscientific tests, it seems moving from PHP5.4 with xcache to PHP 5.6 with Zend’s OpCache can lead to approximately 50% memory reduction. (xcache was set to have a 64mb size, Zend OpCache is also using 64mb of memory).

  • ack-grep config – ackrc – adding new file types

    I needed to add some more file types for ack-grep to find / search when I’m looking for PHP code that resides in files with non-standard extensions (e.g. something.def, etc).

  • PostgreSQL unbuffered queries and PHP (cursors)

    From using MySQL, I’ve used the ‘unbuffered queries‘ feature a number of times. It’s where you don’t fetch the entire resultset into memory at once – which is necessary if you’re retrieving more data than you have memory available. If’s often also generally gets results/data back to you sooner.

  • WordPress comment spam post fail

    While trying to block spam posts on a forum, I noticed this gem. No doubt someone’s spam sending program has failed, just a little….