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

Remi Collet:
Microsoft SQL Server from PHP
Sep 23, 2016 @ 11:57:34

In this recent post to his site Remi Collet shows you how to set up your PHP installation to allow it to work with a Microsoft SQL Server as it's data store.

Here is a small comparison of the various solutions to use a [Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server) database from PHP, on Linux. All the tests have be run on Fedora 23 but should work on RHEL or CentOS version 7.

Several different extensions were tested as a part of making the connection to the SQL server:

  • Using PDO, ODBC and FreeTDS
  • Using PDO, mssql and FreeTDS
  • Using PDO, ODBC and Microsoft® ODBC Driver
  • Using the Microsoft® Driver
  • Using PDO and the Microsoft® Driver

Each item comes with a list of the requirements involved (other modules/extensions), examples of the configuration changes you'll need to make and some sample code to create the connection.

tagged: tutorial microsoft sql sqlserver database connection example testing

Link: http://blog.remirepo.net/post/2016/09/20/Microsoft-SQL-Server-from-PHP

TutsPlus.com:
Building a Welcome Page for Your WordPress Product: Code Part 1
Sep 23, 2016 @ 10:33:58

TutsPlus.com has started off a new series of posts for the WordPress users out there showing you how to build a "welcome page" for your WordPress site and product.

In the first two articles of this series, I wrote about what welcome pages are and how they are helping products improve user experience by connecting the dots, after which I wrote about the WordPress Transients API that I intend to use while building the welcome page.

Coding a welcome page for your WordPress plugin can be a tricky process. The entire concept revolves around redirecting users to a particular page via setting transients and finally deleting them. Let's start building the welcome page.

They walk you through the creation of a simple plugin that can be used to easily create (and re-create) these "welcome" pages (the final result is here for the impatient). The tutorial the starts off by defining the architecture of the plugin and the workflow that it will follow to generate the page. From there it gets into the code for the plugin itself and related supporting files including the "initializer" that activates the plugin, making it ready for use.

tagged: welcome page wordpress plugin series part1 tutorial

Link: https://code.tutsplus.com/articles/building-a-welcome-page-for-your-wordpress-product-code-part-1--cms-26014

TutsPlus.com:
Building Your Startup With PHP: Simplifying Onramp With OAuth
Sep 22, 2016 @ 12:45:49

The TutsPlus.com site has posted the next part of their "Build Your Startup with PHP" series today. This time they show you how to make it even easier for the users of your site to sign up using OAuth and third-party authentication.

In this tutorial, I'll guide you through implementing OAuth integration with common social networks to make signing up and repeated usage easier and more efficient. I'll explore Facebook, Google, Twitter and LinkedIn, the networks I see as being most appropriate to Meeting Planner's target users.

The tutorial makes use of the Yii framework's own AuthClient functionality to make the actual requests to the 3rd party services. They help you get it installed via Composer and the configuration changes you'll need to make for it to be available and functional.

The tutorial then shows how to create developer applications on a few different services: Twitter, Facebook, Google and LinkedIn. They help you update your configuration with the secret keys for each and create a new database update for storing the 3rd party identifiers when the connection is made. Finally they hook it into the user profile and the login page for use by your users.

tagged: startup series tutorial oauth connection thirdparty service integration authclient

Link: https://code.tutsplus.com/tutorials/building-your-startup-with-php-simplifying-onramp-with-oauth--cms-23512

Master Zend Framework:
Whoops, I Forgot The Error Handler
Sep 21, 2016 @ 12:57:32

The Master Zend Framework site has posted a new tutorial for those out there looking for a bit more from their error handler than just some basic text. In this tutorial Matthew Setter introduces you to the Whoops error handler and how to use it in your Zend Expression application.

Ever experienced HTTP 500’s, but found that your error logs are empty. Ever had no clue why or how this could be happening? Perhaps you forgot to enable the Whoops error handler.

That’s right, perhaps, when you were setting up a Zend Expressive application, you made the mistake which I made recently when you used the Zend Expressive Skeleton Installer. [...] If you chose n, and used a templating engine, then TemplatedErrorHandler, would have been used as PHP's default exception handler.

As a result, no exceptions will be written in your logs. Sure, you’ll see that a 500 error has occurred somewhere in your application. But, the only information you’ll have is [a simple 500 error message].

He notes that the next step for most developers is the log files, trying to find a hint there of what might have broken. If you chose the default logger, nothing will be there as it captures those issues and pushes them to the basic error template (but doesn't output them). He points to where in the configuration you can check to see if you enabled the Whoops error handler and how to test it after you've made the switch. The reason the default is the basic message is that, in production, you don't want information exposed and log messages/code shown to just anyone - that's a big security risk.

tagged: whoops error handler zendexpressive enabled tutorial output

Link: http://www.masterzendframework.com/whoops-errorhandler/

Loïc Faugeron:
Mars Rover, Locating handler
Sep 21, 2016 @ 10:39:30

Loïc Faugeron continues his "Mars Rover" series of posts today with the latest in the series covering the "Locating" handler, the functionality responsible for handling requests for the rover's location.

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

He makes use of the command bus pattern to create the handling for the module, doing validation in the Command object and a Bus to handle the command and perform its task. He starts, as usual, with the phpspec tests defining a class that can use a "find latest location" type instance and a "find" method to abstract out the location repsonse.

tagged: mars rover tutorial series location handler phpspec

Link: https://gnugat.github.io/2016/09/21/mars-rover-locating-handler.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/

CloudWays Blog:
Getting Started With Silex Micro-Framework On Cloud Hosting
Sep 19, 2016 @ 11:54:34

On the CloudWays blog they've posted a tutorial that introduces you to the Silex framework, a product from SensioLabs of Symfony fame and using it on a cloud hosting platform (their own).

Extensibility is one of the main aims of web app development projects. However, there are times when you need to get things up and running as soon as possible and with minimum time dedicated to coding. This is where micro-framework s really outshine the competition. There is a long list of these frameworks including Silex, Slim, Lumen, etc. These are ideal for developing small-scale applications with clean code and user defined directory structures.

In this tutorial I am going to explain how to install Silex, its operation, directory structure, Routings and HTTP Requests. Silex is a micro-framework written in Symfony and inspired by Sinatra, a DSL for quickly creating web applications in Ruby with minimal effort.

They start by helping you get the CloudWays instance up and running with their "PHPStack" setup. Once created they show how to get to a command prompt, make the public HTML directory and use Composer to install Silex and Twig (for templating). The tutorial then briefly covers the directory structure for the site and the code to create the Silex application instance. They define some of the basic routing (to work with book data) and show the handling for sending feedback submitted via a simple page. The remainder of the tutorial shows the use of different features of Silex including: providers, middleware, before/after handlers and defining controllers as classes.

tagged: silex introduction tutorial microframework symfony

Link: https://www.cloudways.com/blog/install-silex-on-cloud/

Freek Van der Herten:
Taking care of backups with Laravel
Sep 19, 2016 @ 09:34:13

Freek Van der Herten has posted a new article to his site covering the backup of your Laravel-based application with a handy package, laravel-backup. He's released a new major version so he wanted to catch you up on some of the features and functionality the package includes and how to use them for your application.

A new major version of laravel-backup was recently tagged. This package can backup files and databases of your Laravel app (or any PHP application really). The backup consists of a zipfile containing a dump of the databases and all files that are selected for backup. The package will copy over the zipfile to external storage such as S3, Dropbox, SFTP, … If something goes wrong during the package can notify you via, amongst others, mail or Slack. In this post I’d like to give some background on why and how it was built.

Keep in mind that there is no one size fits all solution for backups. A small company will probably handle backups in another way than a bigger company. This post has small companies in mind with a couple of developers and no dedicated operations person or team.

He starts off talking about "modern hosting" services and some of the issues that can come with them (downtime being one of the worst). He point out that providers like Linode and DigitalOcean only make periodic backups of your application and restoring from these could mean a lot of data loss - one of the worst things that can happen to an online business. With the laravel-backup package protecting against this kind of failure is easier, letting you automatically back up your site to an off-server source (like S3, Dropbox, or even another local location). He also describes the handling to clean up old backups, sending notifications when problems come up and simple monitoring functionality. He ends the post by mentioning once again that this package is designed for use with small-to-medium sized applications. Larger ones should work up a more robust, possibly external solution that doesn't rely on the application framework for its functionality.

tagged: backup laravel package laravelbackup tutorial downtime

Link: https://murze.be/2016/09/taking-care-of-backups-with-laravel/

Johannes Schlüter:
JSON Aggregation functions
Sep 16, 2016 @ 11:53:25

Johannes Schlüter has written up an article covering an interesting feature of the latest MySQL server release related to its JSON column handling: JSON Aggregation functions.

[The JSON datatype, functions and generated columns] combined allow building very powerful applications without committing to a fixed data structure on every part, but I was missing one thing a lot: Aggregation.

A topic I'm thinking a lot about is finding ways to select nested data. In MySQL we typically have two ways for this. Either one sends multiple queries to retrieve different nesting levels or one builds JOINs which tend to deliver repetitive responses.

He points out that one solution is the GROUP_CONCAT function, but the results of this can be difficult to work with and larger data may override the small memory space allowed. Instead he introduces two new functions in v8 to help with this nested data selection: JSON_ARRAYAGG and JSON_OBJECTAGG. He provides a brief example of the use of these two functions together to replace the "concat" handling from before.

tagged: mysql json function v8 release aggregation tutorial

Link: http://schlueters.de/blog/archives/183-MySQL-8.0-JSON-Aggregation-functions.html

TutsPlus.com:
Building Your Startup With PHP: Email Commands
Sep 15, 2016 @ 11:22:40

TutsPlus.com has continued their "Building Your Startup with PHP" series in this latest tutorial covering the use of email commands in their "Meeting Planner" example application.

This tutorial is part of the Building Your Startup With PHP series on Envato Tuts+. In this series, I'm guiding you through launching a startup from concept to reality using my Meeting Planner app as a real-life example. [...] In the last tutorial, we began emailing meeting invitations which included numerous links for participants to respond, i.e. view the meeting page, accept all places and times, reject a place or time, etc.

In this tutorial, I'll review how I chose to construct and process those links in a secure, functional manner.

He then starts in on the idea of "commands" explaining a bit about what they are and what kind of commands are needed for the planner application. Code is included to create some of these commands and how to integrate them into the rest of the Yii-framework based application.

tagged: startup build tutorial series email command yii framework

Link: https://code.tutsplus.com/tutorials/building-your-startup-with-php-email-commands--cms-23288