All pages in the Php category

Make PHP More Useable - Returning Multiple Values from Functions

Use Golang inspired pattern to easily return multiple values from PHP functions.

Thursday Jul 16, 2015 — 2 minute read — 395 words

If you’ve ever used Go it’s hard to not find returning multiple values from functions conspicuously absent in other languages. In this case, we’ll look at a simple way to implement the same design pattern effectively in PHP. Why It’s Useful So why return multiple values from a function anyway? If you’ve never used Golang or a similar language which allows that, it may not be readily obvious. Most use-cases in Golang are centered around errors, so it’s very easy to check if a function encountered a error.

Read More

Installing APC and Xdebug on Ubuntu 14.04 LTS (Trusty Tahr)

Get up and running with APC and Xdebug in the latest stable version of Ubuntu

Monday Jun 30, 2014 — 2 minute read — 323 words

Installing APC and/or Xdebug for PHP on Ubuntu 14.04 isn’t hard, but requires knowing a few small bits of information, particularly if you’re planning on using Xdebug with command-line PHP scripts. Install Xdebug If You Don’t Need Xdebug on CLI If you need Xdebug only through Apache, installing it is as simple as: sudo apt-get install php5-xdebug If you need Xdebug on the command-line (CLI) then it’s a bit more work, since it’s Xdebug on the command-line via the php5-xdebug package is disabled.

Read More

Testing with Silex and PHPUnit

Getting started with unit testing using PHPUnit in your Silex project.

Monday Jun 30, 2014 — 2 minute read — 370 words

This took a bit to figure out, so I’m posting it here in hopes it may be helpful. I use the Silex microframework a lot, and love it. Setting up testing, though, can be a bit tricky if you don’t know what to look for. First off, the docs on the Silex site are great. They will definitely get you started, but they seem to be missing a couple of critical explanations that may trip you up.

Read More