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

Symfony Finland:
Symfony Flex set to enable RAD (Rapid Application Development)
Dec 05, 2016 @ 11:58:37

On the Symfony Finland site there's a post that gets into the details of one of the new advancements in the Symfony ecosystem recently announced by Fabien Potencier at SymfonyCon Berlin 2016 - Symfony Flex.

The Symfony team has acknowledged this gap in their offering. And at SymfonyCon Berlin 2016 project lead Fabien Potencier announced what is known as Symfony Flex. Details are not precise, as I was not attending conference, but the tag line for Symfony Flex is: "Composition over Inheritance"

In essence it seems that Flex will allow for zero-config installation of Bundles. This is done using a Composer plugin. You will simply install packages with Composer and if the Bundle supports it, Composer will also author the necessary integration code and configuration.

As with any new thing, Flex support will start out pretty limited but as it grows in support the community should help it thrive in the Symfony ecosystem. The first release of the tooling for Flex will be available in early 2017.

tagged: symfony flex composer package bundle composition installation

Link: https://www.symfony.fi/entry/symfony-flex-to-enable-rad-rapid-application-development

Laravel News:
Getting started with Watson Personality Insights
Nov 25, 2016 @ 14:52:01

On the Laravel News site there's a post showing an application of the IBM Watson Personality Insights service to discover trends and make predictions about future actions/preferences. They also show how to integrate it into your Laravel-based application thanks to this package.

One of the most important things as a business owner is being able to understand your customers’ needs and wants; such that you are able to offer them a personalized experience. This works great if you know your customers on a personal level, but what if you don’t?

[...] Sure you could send out a survey from your site, then collect a huge amount of data, then process, analyze and finally being able to tell what package fits which user. This seems tiresome and plus people’s tastes and preferences change over time and you would have to repeat this process over and over again each time you want to offer them something new. There has to be a better way, and there is.

The post talks about the services offered by IBM Watson and, more specifically, about Personality Insights. They cover some about what this service offers as related to web preferences and link to a demo application you can use to get more context about its handling. The post wraps up showing how to integrate the package into your application and working with requests/responses to the IBM Watson Personality Insights service.

tagged: ibmwatson personality insights tutorial laravel package machinelearning

Link: https://laravel-news.com/2016/11/getting-started-with-watson-personality-insights/

Zend Developer Zone:
Scheduling ElePHPants (DateTime math is HARD)
Nov 18, 2016 @ 12:49:38

On the Zend Developer Zone there's a new post talking about scheduling in applications ("scheduling elePHPants") including both library recommendations and advice about code reuse.

It was while I was creating the 100th or so cronjob to do some very similar to the other 99 that I thought, “Hey! Why not just put all this in a database and check it once a minute instead?” [...] It would be so much easier to deal with in PHP. Also, cron does not scale well at all either in performance or management.

The problem is that cron is an elegant solution for “Do this at that time” type of problems. Every solution I came up with was basically re-creating cron. That in itself isn’t a bad thing, but the logic involved in doing what cron does is mind-melting.

[...] Then it hit me, I am probably not the first person that has had this need. There have probably been other people who needed to implement “Do this at that time” within a PHP application. So I started looking around. What I found was encouraging.

The author then mentions several packages that he went through searching for the right solution to his problem, noting that while Laravel-based solutions seemed nice, they wouldn't work with his framework choice (Slim). He decided on the cron-expression package, finding it to be the best fit for the project's needs.

I had spent countless hours trying to create the solution myself. [...] I got so lost in solving the problem, I forgot to look to see if someone had already solved it. [...] After I finally came to my senses, I tweeted that out to remind myself to “Use the Source”.
tagged: schedule task cron experience package code reuse datetime

Link: https://devzone.zend.com/7418/scheduling-elephpants-datetime-math-is-hard/

Freek Van der Herten:
An unofficial Forge API
Nov 18, 2016 @ 10:54:09

In this quick post to his site Freek Van der Herten looks at the "unofficial Forge API" you can use to do some (limited) things with your Forge account and servers. Forge is a service in the Laravel ecosystem for managing and deploying servers with a simple and clean frontend interface.

You might not know this but Forge already has an API, it’s just not a documented and feature complete one. Open up your dev tools and inspect the web requests being sent while you do various stuff on Forge.

Marcel Pociot published a new package called Blacksmith (great name Marcel) that can make calls to that API.

The package submits a login form behind the scenes to authenticate but other than that it's normal API calls. The package includes methods allowing you to:

  • get a list of all active servers
  • return server by ID
  • get the listing of sites
  • update metadata
  • get environment information

...among other things. You can find out more about the package in its GitHub repository.

tagged: laravel forge api unofficial package blacksmith

Link: https://murze.be/2016/11/unofficial-forge-api/

Master Zend Framework:
How to Simplify Expressive Configuration with Interop-Config
Nov 17, 2016 @ 09:58:59

On the Master Zend Framework site there's a tutorial posted showing you how to simplify your Zend Expressive configuration with the help of the interop-config package.

Zend Expressive (and Zend Framework) are great frameworks, ones designed not to constrain you in almost any way. You’re in charge. You set the scene. You make it do just what you want it to do. Unlike other frameworks, you’re not bound to work with a specific way. You’re free to work in, almost, whatever way you want. But that comes at a price.

Consequently, using Zend Expressive can give you too much freedom — especially when it comes to configuration. That’s why I was happy to hear about Interop-Config some time ago from my friend Sandro Keil.

Interop-Config is a library which helps ensure that you have a valid configuration for your code. It can provide default options, as well as enforce mandatory options, ensuring that it has a well laid out structure, and is easy to understand.

He starts by briefly talking about the package itself and what kinds of features it brings along with it. The tutorial then shows how to get the package installed and a simple base configuration. With that in place it then shows you how to access this configuration via the "ConfigurationTrait" and a "dimensions" method. From there you can then easily get configuration data from the DI container (and see if it exists with a "canRetrieveOptions" method). The post finishes up showing you how to add default values, making options mandatory and a bit about defensive programming methodologies in using the tool.

tagged: zendexpressive configuration interopconfig package tutorial zendframework

Link: http://www.masterzendframework.com/simplify-expressive-configuration-with-interop-config/

SitePoint PHP Blog:
Beaver in Action: Practical MySQL Optimization
Nov 11, 2016 @ 10:30:49

On the SitePoint PHP blog there's a tutorial posted showing how to optimize your MySQL handling with the help of the Beaver query logger package and the details it provides.

Clients with an existing application sometimes ask me to fix bugs, improve efficiency by speeding up the application, or add a new feature to some existing software. The first stage of this is researching the original code – so-called reverse engineering. With SQL databases, it is not always immediately obvious which SQL queries MySQL executed – especially if these queries were generated by a framework or some kind of external library. In this article, I will talk specifically about MySQL and present a common optimization use case which might come in handy if you run into a similar problem one day.

He shows how to update your MySQL installation to log all queries out to the log location of your choice. This log can then, in turn, be parsed by the Beaver package and provide details about what's happening in the query and where it could be optimized. The article also provides a more "real world" example of a query happening in a Yii2 application resulting in a large number of queries being generated. He shows how to update the query handling to make the loading more efficient (through joins rather than individual queries) and what the resulting statement looked like.

tagged: beaver package mysql optimization query analyze tutorial

Link: https://www.sitepoint.com/beaver-in-action-practical-mysql-optimization/

Tighten.co:
A better dd() for your TDD
Oct 13, 2016 @ 11:57:45

On the Tighten.co blog they have a recent post sharing a better dd() for your TDD - basically a better method for debugging the current state of object with a "dump and die" function.

An important part of every Laravel developer's debugging arsenal is the humble dd() helper function—"dump and die"—to output the contents of a variable and terminate execution of your code. In the browser, dd() results in a structured, easy-to-read tree, complete with little arrow buttons that can be clicked to expand or hide children of nested structures. In the terminal, however, it's a different story.

[...] Fortunately, it's simple to build your very own customized version of dd() to help tame your unwieldy terminal output—helping you find the details you're interested in quickly, without wearing out your trackpad (and your patience).

He provides two options you can use to help clean up the output of a "dump or die" method from the extensive results the current "dd" function provides:

Kint provides a few other helper methods you can use and easily configurable max and min depth to show in the output.

tagged: tdd testing vardumper kint library package output debugging

Link: https://blog.tighten.co/a-better-dd-for-your-tdd

Loïc Faugeron:
Mars Rover, Locating geolocation
Oct 05, 2016 @ 09:04:37

Loïc Faugeron is back with the next part of his "Mars Rover" series (you can find all of the articles so far here with his latest post covering the Locating class' geolocation functionality.

In this series we're building the software of a Mars Rover, according to the following specifications. It allows us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD)

We've already developed the first use case about landing the rover on mars, and the second one about driving it. We're now developing the last one, requesting its location. [...] In this article we're going to create a new package for the geolocation value objects (Location, Coordinates and Orientation).

He starts off by creating the geolocation package and its matching composer.json file. He then creates the phpspec configuration for the package and commits this initial version. He pulls this new package into the larger current codebase and makes an update to the overall phpspec configuration to run its tests. With that in place he updates two related packages, location and navigation, to include the new library before integration (coming in the next part of the series).

tagged: mars rover tutorial series location geolocation package

Link: https://gnugat.github.io/2016/10/05/mars-rover-locating-geolocation.html

Raphael Stolt:
Anatomy of a dope PHP package repository
Sep 22, 2016 @ 09:30:25

In this recent post to his site Raphael Stolt shares an example of what he thinks is a "dope" setup for a Composer package (a well-structured, consistent and fully populated package structure).

While contributing to Construct, maintained by Jonathan Torres, I gathered some insights and learnings on the characteristics of a dope PHP package repository. This post summarises and illustrates these, so that PHP package developers have a complementary guideline to improve existing or imminent package repositories. Jonathan Reinink did a good job in putting the PHP package checklist out there which provides an incomplete, but solid quality checklist for open-source PHP packages.

I'll distill the characteristics of a dope PHP package repository by looking at the repository artifacts Construct can generate for you when starting the development of a new PHP project or micro-package.

Included in his list of things every PHP package should include are things like:

  • the source (naturally), matching tests/specs and documentation
  • consistent naming
  • versioning information (via a CHANGELOG)
  • Travis-CI integration
  • A . gitattributes file for excluding certain files from export

He also makes a few more general suggestions like avoiding the posting of "badges" in the README and some reasons why you should care about the "dopeness" of your repository at all.

tagged: package wellstructured requirements opinion repository

Link: http://raphaelstolt.blogspot.com/2016/09/anatomy-of-dope-php-package-repository.html

Jason McCreary:
Update PHP on Mac OS X
Sep 20, 2016 @ 10:15:26

Jason McCreary has posted an update to his guide for installing PHP on Mac OS X and replacing the version of PHP that comes with El Capitan (5.5) with a handy package manager more specific to PHP installations.

As noted in my posts on Installing Apache, PHP and MySQL on Mac OS X, OS X comes pre-installed with Apache and PHP. Unfortunately, as of Mac OS X 10.11 (El Capitan) the pre-installed version of PHP is still 5.5. As PHP 5.5 has reached end of life, I imagine the pre-installed version of PHP will be updated with Mac OS 10.12 (Sierra). However, it may only be PHP 5.6.

So what do you do if you want to upgrade or install a different PHP version on your Mac? Well, you could use Homebrew. But I found a pre-packaged alternative - PHP OSX.

With this package manager, the installation is only a few steps but he lists them out with a bit more detail to help you understand what's happening:

  • Installing PHP (your choice of version)
  • Configuring Apache (loading the php5 shared module)
  • Updating your PATH
  • Configuring PHP
tagged: osx update language version package simple installation tutorial

Link: http://jason.pureconcepts.net/2016/09/upgrade-php-mac-os-x/