Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Three Devs & A Maybe:
Episode 96 - Application Performance with Jonathan Klein
May 11, 2016 @ 11:57:30

In the latest episode of the Three Devs and a Maybe podcast hosts Michael Budd, Fraser Hart, Lewis Cains and Edd Mann talk with Jonathan Klein about application performance based on some of his work creating the "High Performance PHP" course for Pluralsight.

On this weeks episode we are joined by Jonathan Klein to discuss all things application performance. We start off the show with chat about how he got into performance, why it is so important and how he thinks of it throughout the development process. From here we discuss his recently released Pluralsight course on ‘High Performance PHP’ and touch upon some of the key performance areas within the stack.

Starting with micro-optimisations at the code level, we highlight their value and caching mechanisms. We then move onto the web server, process managers and the importance of a correct configuration. The Database layer is then brought up, discussing forks of MySQL, handling slow-queries and data-denormalizations. Finally, profiling and monitoring tools are discussed (such as New Relic and Seige) and where you can typically find the most wins within a typical stack.

They talk about his Pluralsight course as well as other topics like feature flagging, caching, atomic deployments and MariaDB vs MySQL. You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to also subscribe to their feed to get the latest shows as they're released.

tagged: threedevsandamaybe ep96 application performance jonathanklein podcast

Link: http://threedevsandamaybe.com/application-performance-with-jonathan-klein/

Symfony Blog:
PHP-PM grows up to be a credible option for high performance PHP
Apr 25, 2016 @ 12:29:58

On the Symfony Finland site there's a post about a relatively new way to run PHP applications and how it's "growing up" to become a viable option: PHP-PM.

PHP-PM is a novel way of running PHP applications. Instead of creating an exotic high performance runtime for the PHP language, it takes an alternative route to mechanism of running PHP applications with existing runtimes.

This translates to real performance gains with existing complex applications, not just impressive theoretical benchmark results.

Instead of the usual complete bootstrap that normal PHP process goes through in its lifecycle, PHP-PM runs them as a continuous process, making for a huge boost in overall performance. The project has started gathering more momentum and is being worked on to make it a more credible platform for PHP applications.

From the humble beginnings the PHP-PM now has over 1700 stars on GitHub and a number of developers working on it. Great strides have been done since the early stages with the documentation and ease of use, but most importantly the platform now supports multiple frameworks: Symfony, Zend and Laravel.
tagged: phppm process option high performance application project symfony

Link: https://www.symfony.fi/entry/php-pm-grows-up-to-be-a-credible-option-for-high-performance-php

SitePoint PHP Blog:
PredictionIO and Lumen: Building a Movie Recommendation App (Part 2)
Apr 06, 2016 @ 14:30:42

The SitePoint PHP blog has posted the next part in their series about using Predictive.IO and Lumen to create a simple movie recommendation application (part one is here). In this second part of the series they build on the environment created in the previous article and start developing the actual application.

In the intro, we covered the basics of PredictionIO and installed its dependencies. In this part, we’re going to build the movie recommendation app.

The tutorial starts with a brief configuration section to ensure you have your API keys configured correctly. Then it gets into the code:

  • Pulling the data from the Movie DB API
  • Creating the endpoint to perform the endpoint
  • Picking random movies to show the user and recording their reactions (like/dislike)
  • Creating the endpoint to recommend movies

Finally they share the configuration to set up the application deployment and train it with some example content you provide through some basic interactions. Finally they help you set up a cron job to train and redeploy the application every five minutes with the latest interaction information.

tagged: tutorial predictionio series part2 movie recommendation implement application

Link: http://www.sitepoint.com/predictionio-and-lumen-building-a-movie-recommendation-app/

SitePoint PHP Blog:
PredictionIO: Bootstrapping a Movie Recommendation App
Apr 05, 2016 @ 11:22:11

On the SitePoint PHP blog they've posted a tutorial showing you how to use the Prediction.IO server to create a movie recommendation application. Prediction.io is "an open source Machine Learning Server built on top of state-of-the-art open source stack for developers and data scientists create predictive engines for any machine learning task".

In this tutorial, I’m going to walk you through PredictionIO, an open-source machine learning server, which allows you to create applications that could do the following: recommend items (e.g. movies, products, food), predict user behavior, identify item similarity and rank items.

You can pretty much build any machine learning application with ease using PredictionIO. You don’t have to deal with numbers and algorithms and you can just concentrate on building the app itself.

The tutorial, the first part of a series, refreshes some older instructions for getting the Prediction.IO system up and running. He walks you through the creation of an AWS instance for the server a few different ways (Vagrant, Docker, etc). He then talks about the use of the Movie API from MovieDB and the two parts of the application that will be implemented on top of it: a learning phase and a recommendation phase. They show how to use Prediction.io to create the recommendation engine and make the new application on top of it. He helps you install some dependencies to use in the PHP side of the application and briefly explains what they're for.

This wraps up part one of the series. In the second part he starts putting this all to use and creates the PHP functionality to lay on top of the machine learning engine and handle learning and recommendations for users.

tagged: predictionio machinelearning server tutorial movie recommendation application part1 series

Link: http://www.sitepoint.com/predictionio-bootstrapping-a-movie-recommendation-app/

Mohamed Said:
Building an API for 3rd party applications
Mar 30, 2016 @ 09:30:31

In this post to his site Mohamed Said shows you how to build an API that allows for easier integration with your content/functionality by 3rd party applications. This example uses the Laravel framework but the ideas could be applied in any framework.

APIs are cool, & laravel can handle all the coolness you may desire. Here we talk about building an API for third party applications and allowing them to communicate with your application on behalf of users.

He starts where any good project should: planning for what features need to be included and the flow of the request/response process. He then walks you through the whole process for setting up the API:

  • Updating the routes for the API request endpoints
  • Creating the new Auth and Home controllers
  • Setting up the migration for the "applications" table
  • Using the firebase/php-jwt library for authentication/authorization handling
  • Registering a token and validating it on the incoming request

He wraps up the post talking about user authentication via a simplified OAuth-ish process flow, making requests using the resulting token and logging the user out (expiring the token).

tagged: api tutorial laravel application integration jwt token authentication authorization

Link: http://themsaid.github.io/laravel-api-3rd-party-20160327/

Semaphore CI Blog:
Dockerizing a PHP Application
Mar 24, 2016 @ 13:06:09

On the Semaphore CI blog they've posted a great tutorial that wants to help you Docker-ize your PHP application and deploy the application easily out to Heroku (with some help from Semaphore, naturally).

In this tutorial, you will learn what Docker is and how you can use it to create sophisticated working environments. If you already have experience using VMs such as VirtualBox, Vagrant, etc., you'll grasp the concept quickly.

To make things more concrete, we will use a demo application which interacts with the 500px API to list popular photos, view, upvote and comment on them. The application is built using Laravel 4, but this shouldn't present an issue in our case.

They start with a brief introduction to what Docker is for those not familiar with the technology and some of the requirements you'll need to use it. They help you get Docker installed on your local system and how to work with Docker images and containers to create a custom environment for the Laravel application. Next, he talks about Dockerfiles (configurations for Docker), spinning up the environment and an alternative to manual commands: Docker YAML configuration. The next move is to deploy to Heroku using the "heroku' command line tool and integrating it all with Semaphore for continuous deployment.

tagged: docker application laravel configuration setup container tutorial

Link: https://semaphoreci.com/community/tutorials/dockerizing-a-php-application

Medium.com:
How to scale Laravel horizontally with Docker
Mar 24, 2016 @ 11:16:19

In this new Medium.com post Andrew McLagan shows you some strategies you can use to scale your Laravel application horizontally with the help of Docker and a relatively simple configuration.

Homestead was created by Taylor [Otwell] to ease creation of PHP development environments, it offers developers a consistent environment across projects and is fully compatible with the Laravel ecosphere.

[...] Docker is basically programmable infrastructure, or more simply: Docker lets you create a server environment for your project from a configuration file. [...] I will demonstrate the power of the Docker ecosystem through another tool called Docker Compose a container orchestration tool built upon Docker. This tool enables us to start multiple Docker containers at once from a single configuration file, rather then starting each container individually.

He shows you how to get the required tools installed including a fresh Laravel installation. He then includes the Docker YAML configuration to create the environment, setting up a load balancer, Redis, MySQL and a HHVM instance. He then creates the docker machine to tie all of the pieces together as a VirtualBox VM instance. With this setup up and running, you can then test a URL to be sure the Laravel install is up and running correctly. He then gets to the horizontal scaling part and talks about docker's "scale" functionality making it simple to set up multiple "web" container instances to handle the incoming requests.

tagged: laravel application scale docker horizontally tutorial virtualmachine container

Link: https://medium.com/@andrewmclagan/you-thought-laravel-homestead-was-easy-say-hello-to-docker-2c0639a0501#.ordx0lrwv

Paul Jones:
Why Do PHP Developers Think MVC Is An Application Architecture?
Mar 16, 2016 @ 11:49:51

In a new post to his site Paul Jones wonders out loud about why developers think MVC is an application architecture versus just a user interface pattern.

I’ve pointed out before that Model-View-Controller is a user interface pattern, not an application architecture. But why would PHP developers get the idea that MVC is an application architecture in the first place?

[...] I used to think that MVC was an application architecture. Even after reading Fowler’s POEAA and seeing that MVC was for the user interface, I figured that meant I was doing “user interface applications.” But that was not quite right; it would have been more accurate to say that I had been mixing the concerns of user interface with the underlying core application.

He suggests that the reason MVC is commonly thought of as an architecture is because of the "flow" most PHP developers follow in their learning and development practices. Starting from "page scripts" where things are all mashed together, a developer then learns about the separation of concerns and how MVC helps splitting up the application easier. Paul includes a reminder, though, that the "user interface" isn't really just the frontend parts (HTML, CSS, JS) but the HTTP request/response to and from the application.

tagged: mvc modelviewcontroller application architecture progression developer opinion

Link: http://paul-m-jones.com/archives/6288

DotDev.co:
Step by Step Guide to building your first Laravel Application
Mar 07, 2016 @ 09:25:04

On the DotDev.co site they've posted a tutorial showing you how to create your first Laravel application. In their case they show how to create a simple link collection tool to help illustrate the process.

The Laravel framework has experienced exponential growth since it’s initial release in 2011. In 2015 it became the most starred PHP framework on GitHub and has risen to be the go-to framework for people all over the world. [...] My goal with this is to create a guide for those just learning the framework. It is setup to take you from the very beginning of an idea into a real deployable application.

He starts by pointing out some prerequisites you'll need (like a local PHP environment and having PHPUnit installed). He then gets into the first step in any good application, planning, and some recommendations to think about. Once the planning is done, then the real code starts. He's broken it up into a few sections to help make it easier to follow:

  • The first steps (setting up the basic Laravel application)
  • Building a list of links
  • Submitting Links

In each step he also provides examples of tests that can be written and used to ensure your application is working as expected. Templates for the link output and the submission form are also included.

tagged: laravel application introduction beginner links tutorial first

Link: https://dotdev.co/tutorials/step-by-step-guide-to-building-your-first-laravel-application/

SitePoint PHP Blog:
Websockets in Your Synchronous Site
Feb 26, 2016 @ 11:03:53

The SitePoint PHP blog has a new tutorial from Christopher Pitt showing you how to integrate websockets into your application for asynchronous, real-time functionality. His method makes use of a service called Socketize (with a free tier available).

Asynchronous architecture is common in other programming languages, but it’s only just finding its feet in PHP. The trouble is that this new architecture comes with a cost.

I don’t talk about that cost enough. [...] When I recommend frameworks like Icicle, ReactPHP, and AMPHP, the obvious place to start with them is to create something new. [...] It takes a lot of work to integrate new, asynchronous features into existing applications. Often there are good reasons and great benefits, but a rewrite is always a hard-sell. [...] I’m going to show you a Sockets-as-a-Service service, called Socketize.

He walks you through the setup of the code and account to create a simple CRUD (create, read, update, delete) system for a deck of cards. He starts with a simple synchronous API spitting back JSON of the card data. Then he creates the frontend client (simple Javascript) to fetch the data and append the values to the page. Next comes the asynchronous handling - he shows the creation of the Socketize account, setting up a new application (with keys) and making use of the SocketizeJavascript client to create the websocket and hook it all together.

tagged: websockets asynchronous socketize application frontend service thirdparty

Link: http://www.sitepoint.com/websockets-in-your-synchronous-site/