Christopher JonesRouting PHP memcached calls to Oracle Coherence (19.8.2014, 18:30 UTC)

A new post Getting Started with the Coherence Memcached Adaptor from David Felcey shows how PHP memcached calls can automatically be routed to store data in Oracle Coherence 12c. This is possible now Coherence 12.1.3 supports Memcached clients using the Binary Memcached protocol. David's post shows how the Coherence Memcached adaptor can be configured as a proxy service that runs in the Coherence cluster. There's nothing particular to configure in the PHP application, except to enable memcached.use_sasl = 1

So what is Coherence? It is an "in-memory data grid solution", with a number of advanced features. You can read more in the Oracle Coherence 12C Data Sheet.

Paul M. JonesOn Project Structure; or, The Framework/App Is Not Special (19.8.2014, 15:05 UTC)

(I apologize for the hasty writing here; this subject makes me impatient.)

Reading this post from Code Rabbi makes me reflect on project structure and organization. Frankly, most project structures (as from CodeIgniter, Cake, and all the popular frameworks since then) strike me as misdirected. They’re examples of why the project maintainers think their code is somehow special and different, and that the application built from it is also somehow special and different.

Your framework and application code are not special. Their code does not go in a special place. There’s no need for a top-level “app” directory with its own special subdirectories. There’s no need for a special naming convention to keep your different application-specfic code in specific places.

We had PSR-0, and now have PSR-4, and the Composer autoloader, to handle all that for you. Just use namespaces. All you need for code at the top level of your project is a “src” directory, where all your app code goes, just like all your library code goes in a “src” directory in a library package.

Instead of /app/controllers and /app/models, you have /src/Controller and /src/Model, or however else you want to organize your namespaced code. Then there’s no need for a special autoloading system or for hard-coded paths just for your application-level code. Add one single line to Composer that points to the src directory and voila, everything inside it loads for you.

That’s it. Nothing special. Just like every other library in your system.

(Again, this was hastily written. Please ask for clarficiation if you feel you need it.)

labs @ Qandidate.comOpen sourcing our feature toggle API and UI (19.8.2014, 14:15 UTC)

In our previous post we released our toggle library and showed how to use it in your PHP project, but our goal was to toggle features without the need for a deploy. To accomplish this we created an API with an AngularJS frontend. In this blogpost we’ll show you how the API works and how we use it in combination with the AngularJS frontend.

∞ labs @ Permalink

Lorna MitchellRunning Multiple Versions of PHP (19.8.2014, 13:32 UTC)

When I advise people about upgrading their PHP version, I say things like "just run your test suite with the new version" "just grab the new version and try your site with the built-in webserver". A couple of people recently have asked for more detail on how to actually achieve these things so here's a quick primer on getting new PHP without touching anything to do with your existing PHP installation.

Install Your New PHP Version

(These instructions are for *nix systems; I have literally no idea how it works on Windows)

You will want to download the source code of your desired version of PHP, then compile it. The key thing here is that we'll put this version of PHP in a different location than your operating system would like to put PHP by default - and so we'll avoid overwriting anything.

Go and choose your version from Download it into its own directory somewhere and extract the files.

Now we'll configure the source, but here is the key ingredient: we set a prefix so that it'll be installed into a separate directory and not interfere with anything. Make a command like this with your path in:

./configure --prefix=/path/to/toy/php

Now we're all set and we can compile the code and install it to the related location:

make install

The make step builds the binaries and the make install step moves them to the correct location - so you may need to sudo make install if your user doesn't have write permission to the location you set in the prefix earlier on.

You're basically done :) Check everything is working by doing:

/path/to/toy/php/bin/php -v

This should show you what version of PHP you just built.

Checking Your Application With Your New PHP Version

Whatever you have in place for your usual test/build process, you can go through and have it use your /path/to/toy/php/bin/php everywhere it would usually run a php command. This can mean fiddling with environment variables or hardcoding paths in places while you try this out - so if you modify your tools make sure you're making those changes on a branch in your source control tool.

To test out your code with the webserver, you just need to start it using the new PHP version. For me, that command looks like this:

/path/to/toy/php/bin/php -S localhost:8080

I am seeing more PHP projects being upgraded now, where once they would have been shipped onto a set version, deployed to the server, and left there until they needed replacing. Now we build applications, not just websites, and those need to grow and live along with the companies they exist to serve. The much smoother upgrade process in PHP as well as tools like the webserver make upgrading platforms a perfectly advisable thing to do and I hope the outline above helps someone to make that leap!

Lorna is an independent web development consultant, author and trainer, available for work (interesting projects only). This post was originally published at LornaJane

Cal EvansInterview with Tess Flynn and Larry Garfield (19.8.2014, 05:00 UTC) Link
SitePoint PHPFine Tuning Drupal Themes with Patterns, Arg and Types (18.8.2014, 16:00 UTC)

In this article, we’ll discuss how you can leverage various Drupal API functions to achieve more fine grained theming. We’ll cover template preprocessing and alter hooks using path patterns, types and args(). We’ll use the arg() function which returns parts of a current Drupal URL path and some pattern matching for instances when you want […]

Continue reading %Fine Tuning Drupal Themes with Patterns, Arg and Types%

labs @ Qandidate.comA new feature toggling library for PHP (18.8.2014, 14:15 UTC)

Adding features to an existing application can seem straightforward, but what if the system you need the feature in is already running in production and the feature needs small bug fixes from time to time? Or what if developing a feature takes longer than a standard release cycle, so it can’t be rolled out yet?

∞ labs @ Permalink

Thomas WeinertFluentDOM + HTML5 (17.8.2014, 12:59 UTC)
HTML 5 is not directly supported by PHPs DOM extension. That means FluentDOM can not understand it, too. But here is a solution. HTML5-PHP is library that can parse HTML5 into a DOM document.

Both libraries use Composer:
"require": {
  "fluentdom/fluentdom": "5.*",
  "masterminds/html5": "2.*"

Read HTML5 into FluentDOM:
$html5 = new Masterminds\HTML5();
$fd = FluentDOM($html5->loadHTML($html));

Or write it:
echo $html5->saveHTML($fd->document);

HTML5-PHP puts the elements into the XHTML namespace. To use XPath expressions, you will need to register a prefix for it:
$html5 = new Masterminds\HTML5();
$fd = FluentDOM($html5->loadHTML($html));
  'xhtml', ''
echo $fd->find('//xhtml:p')->text();
SitePoint PHPAPIfy Your Legacy App with Toro (16.8.2014, 18:00 UTC)

For the Google Summer of Code 2014, I was selected for a project to create a REST API for ATutor. ATutor has hundreds of thousands of lines of code, yet is written in core PHP. Introducing a PHP router class for the API was necessary, but we needed something unintrusive. In this post, we discuss the essential parts of the project. For this post, all code examples would correspond to my fork of ATutor’s repository (links to files will be provided whenever necessary).

Note - Google Summer of Code is a program where students all around the world can participate in open source projects of mentoring organizations. Google organizes the program and pays the stipends, but the students are not employed by Google at any point during the program.

Web Routing with Toro

The first step in the process was to create or write a PHP class to perform the routing. After considering a few options, we decided to go with Toro, a the light weight PHP router. It performs just the routing - nothing more, nothing less. The syntax is pretty intuitive and you will get started in minutes.

Toro is RESTful- it has support for the standard HTTP methods- GET, POST, PUT and DELETE. There is support for JSON based requests too. All of this is packed in a 120 odd line file.

Before we proceed, one more step was to configure the server to redirect all requests to the router. This can be performed by adding an .htaccess file in Apache, or changing the configuration file of Nginx. This step of server configuration is explained on the README of Toro’s GitHub repository.

Continue reading %APIfy Your Legacy App with Toro%

Paul M. JonesDRY is about Knowledge (16.8.2014, 15:34 UTC)

From Matthias Verraes:

“Don’t Repeat Yourself” was never about code. It’s about knowledge. It’s about cohesion. If two pieces of code represent the exact same knowledge, they will always change together. Having to change them both is risky: you might forget one of them. On the other hand, if two identical pieces of code represent different knowledge, they will change independently. De-duplicating them introduces risk, because changing the knowledge for one object, might accidentally change it for the other object.

This is a great observation, one I had not considered before. It makes me feel a lot better about the very few and very minor duplications of code in the various independent and decoupled libraries in Aura. In short, DRY is not a reason to couple code libraries with similar behaviors; instead, it is a reason to have a single canonical source of knowledge within a system.

LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP