All pages in tagged with #Php

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

Anahita Social Custom Development Workflow

Ensure you get the latest code without overwriting custom core changes.

Monday Jul 14, 2014 — 2 minute read — 394 words

Anahita is a cool open-source social networking platoform written in PHP. It has a super-active, helpful community lead by Rastin Mehr. If you’re working on a website that’s powered by Anahita, you’ll want to keep up-to-date with the latest code changes via composer. If you’re not familiar with Composer, visit the project homepage to get up to speed. Updating the Anahita Codebase Updating the Anahita codebase is trivial with composer. Just cd into the root directory and run the following to get the latest and greatest: composer update Before you do that, though, read on.

Read More

Anahita Social HTTP Authentication

Integrating HTTP Authentication into Anahita social core

Monday Jul 14, 2014 — 3 minute read — 560 words

Here’s how to solve another potentially tricky challenge when developing third-party integrations with the Anahita social networking platform. The current version of Anahita (3.0.x) uses Joomla and the Nooku framework to provide an out-of-the-box JSON api. It’s cool and it seems to work well. One neat (but hidden) feature is that it supports standard HTTP authentication. That’s super, as there’s no need to worry about using cookies for authentication, allowing for more or a classic stateless REST experience.

Read More

Using Symfony Console with Silex

Integrating console tools into your Silex project.

Tuesday Jul 1, 2014 — 3 minute read — 632 words

The Symonfy console component is a powerful, effective way to define and organize you’re project’s command line PHP scripts. Thankfully it’s quite easy to get it up and running. Installing the Provider It’s easy to install and register the console provider using the knplabs/console-service-provider package. Just this to your composer.json file: "require": { "knplabs/console-service-provider": "dev-master" } You can register the provider with the following lines of code. Obviously, you’ll need to update the, console.version, and console.project_director to match the appropriate values.

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