Pragmatism in the real world

Manuel Stosic: Understanding Zend Framework 3 before it's out

Manuel Stosic has posted Understanding Zend Framework 3 before it's out ZF3 is not close around the corner. It’s still many, many months ahead. But there are reasons why you should bother and get information about ZF3 as soon as possible. Manuel goes on to explain that you can find out information about ZF3's development on Google Moderator, PRs on GitHub, the wiki and an upcoming Hangout next week.

Lorenzo Ferrara: Testing Apigility Code-Connected REST API

Lorenzo Ferrara has posted Testing Apigility Code-Connected REST API First thing, I've installed Apigility following the readme on GitHub, opened the admin interface and clicked on the "Get Started!" button. Things are pretty straightforward: added the new API clicking on the "Create New API" button located in the top-right corner, typed in FortuneCookie and pressed the "Create API". Next thing, I've added the new Code-Connected REST service called OpenCookie. So far so good. He goes… continue reading.

Investigating Apigility

At ZendCon 2013, Zend announced Apigility which is intended to ease the creation of APIs. It consists of these things: A set of ZF2 modules that do the heavy lifting of creating an API A application wrapper for creating standalone web API applications A built-in administration website for use in development to define the API Rather nicely, it supports REST and RPC and deal with error handling, versioning & content negotiation for you. Getting started… continue reading.

Changing the GitHub IRC hooks notification events

As joind.in uses GitHub to host its source code, we use the IRC hook to receive notifications to the IRC channel (#joind.in on freenode) when interesting things happen on the GitHub repositories. We noticed recently that we were being notified about more types of things happening on some repositories compared to others, so I decided to investigate. The code for this is here and a quick perusal of it shows that it will do something… continue reading.

Returning JSON errors in a ZF2 application

If you have a standard ZF2 application and accept application/json requests in addition to application/html, then you have probably noticed that when an error happens, HTML is created, even though the client has requested JSON. One way to fix this is to create a listener on MVC's render event to detect that an error has occurred and substitute a JsonModel in place of the ViewModel. The easiest way to do this in your ApplicationModule. Firstly,… continue reading.

rst2html does not support :startinline:

I'm currently writing some documentation in Restructured Text that I'm targeting at HTML and PDF using rst2html and rst2pdf. For syntax highlighting, both rst2html and rst2pdf use Pygments, however rst2html doesn't support any Pygments options. So a typical PHP snippet in rst targeting rst2pdf, would be written as: .. code-block: php :startinline: true $this = str_replace('foo', 'bar', $that); The startinline Pygments option is to allow it to highlight the snippet, even though the opening <?php… continue reading.

Setting up Zend Server 6 on OS X for PHP development

I recently decided to upgrade my Mac's PHP to 5.4. One of the available options is Zend Server 6.1, Free edition. These are my notes how to set it up so that it works the way I develop. Installation Mount the disk image and follow the installation wizard. On OS X, Zend Server installs PHP, Apache and MySQL inside /usr/local/zend. The Zend Server admin interface is at at http://localhost:10081. On first run you have to… continue reading.

Password less command line scripts with MySQL 5.6

I have a number of command line scripts that copy MySQL databases down from staging servers and store them locally. These scripts set the password on the command line using the -p option. With MySQL 5.6, a new warning is displayed every time my scripts run: Warning: Using a password on the command line interface can be insecure. This is annoying! The way to solve this is to use the new command line tool mysql_config_editor… continue reading.

Configuring a ZF2 view helper before rendering

The currencyFormat view helper is very easy to use: echo $this->currencyFormat($value, 'GBP', 'en_GB'); When I was reading the documentation for the currencyFormat view helper, I discovered that you could configure the currency code and locale once rather than in every call: // Within your view script $this->plugin("currencyformat")->setCurrencyCode("GBP")->setLocale("en_GB"); This is obviously useful, but even more useful would be if we could set it once by default and then override if we need to in a specific… continue reading.

Using PHP's NumberFormatter to format currencies

I've been using number_format() for a very long time, but recently discovered that within the intl extension there's a NumberFormatter class available too. This is quite a clever class as it is Locale aware and handles formatting currency, including the correct symbol. You can check if you have the intl extension installed using php -m | grep intl and if you don't then you can install it with apt-get install php5-intl or yum install php-intl… continue reading.