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

Lanre Adelowo:
A Subtle Introduction to Mocking
Dec 08, 2016 @ 12:16:10

Lanre Adelowo has a recent post to his site introducing you to some of the basics of "mocking" in unit testing, some of the reasons to use it and plenty of examples of it in action using the Mockery library.

Mocking is simply the process of replacing an object with a fake that can act as a replacement. [...] The major reasons why we mock are Dependency elimination and removal of side effects. Think things like databases, 3rd party API requests and network requests, code that has to hit the filesystem.

This stuffs aren’t always guaranteed to be available or can prove tedious to set up (an internet connection for example) and even when they are (a logger that writes to the filesystem for example), they always tend to make your tests run extremely slow.

After covering some of the basics of mocking he talks about how they differ from stubs and how to get Mockery installed. He illustrates some of the basics concepts with a "user search" functionality based on a API request to GitHub. He's writing the results to the file system (via a Logger) so this is the main target of the mock. He creates a mock "FileSystem" class the Logger is refactored to use. He then mocks this dependency out and defines a "shouldReceive" handler for the call to write the log. This replaces the need for the test to write to the file system and makes it possible to test things in isolation rather than relying on the environment.

tagged: mocking introduction unittest mockery tutorial

Link: http://lanreadelowo.com/blog/2016/12/02/a-subtle-introduction-to-mocking/

TutsPlus.com:
Programming With Yii2: Using Amazon S3
Dec 08, 2016 @ 11:27:16

The TutsPlus.com site has continued their series of posts in the "Programming with Yii2" series with this new tutorial covering the use of the Amazon S3 service for sorting files remotely in your application.

In today's tutorial, I'll walk you through the basics of browsing, uploading and downloading files to and from Amazon's cloud-based S3 storage service. Essentially, I've created a simple storage model and controller as examples which you can extend for your needs.

He starts with a brief introduction to the S3 service (including a video from Amazon themselves) and what kinds of things it could be used for. He helps you get started via the AWS web GUI, creating an S3 "bucket" and viewing their contents. He shows how to get the credentials you'll need to connect to the bucket and defining them in the ini configuration file. The tutorial then shows how to use this AWS extension for Yii2 to connect to and work with the S3 bucket you've created. This includes browsing the content, uploading new files and downloading current ones.

tagged: yii2 framework series amazon s3 file storage download upload tutorial

Link: https://code.tutsplus.com/tutorials/programming-with-yii2-using-amazon-s3--cms-26347

Colin O'Dell:
Installing PHP 7.1 December 2nd, 2016
Dec 08, 2016 @ 10:54:42

With the recent release of PHP 7.1 you might be asking how you can quickly and easily update your current installation, regardless of the platform. Thankfully Colin O'Dell is here to help with this guide to upgrading to v7.1 on multiple Linux distributions, OSX and Windows.

PHP 7.1 has been released, bringing some great new features and enhancements to the language such as nullable types, the iterable pseudo-type, catching multiple exceptions, and much more.

Here's a brief guide on how to install PHP 7.1 on several different operating systems.

He includes instructions for Ubuntu, Debian, CentOS/RHEL, Mac OS 10.6+ and Windows. Complete commands and links to the downloads are also provided. You have no excuse now not to upgrade - get downloading!

tagged: install php71 multiple platform tutorial linux osx windows

Link: https://www.colinodell.com/blog/2016-12/installing-php-7-1

StarTutorial.com:
Sending Email with SES in CakePHP 3
Dec 08, 2016 @ 09:31:21

The StarTutorial site has a new article posted showing you how to send email via SES in a CakePHP 3 application. SES is a service from Amazon Web Services that makes it simpler to send emails, the Simple Email Service (SES).

In this tutorial, we will show you how to set up CakePHP 3 to send email with AWS SES via SMTP. In our opinion, integrating AWS SES with CakePHP 3 by SMTP is more straightforward comparing to API.

They start off with the creation of the "EmailTransport" profile configuration dropped into the main application configuration file (defining connection and credential information). They then show how to create an "email profile" telling the framework to use the SES service definition. Finally they offer some advice about using the SES service on a Google Cloud instance and how to work around some of their port restrictions. CakePHP takes care of the rest, automatically understanding how to work with SES and using it transparently as the mailing service when you send your emails.

tagged: cakephp3 tutorial email aws ses send email configuration googlecloud

Link: https://www.startutorial.com/articles/view/sending-email-with-ses-in-cakephp-3


O'Reilly Web Development Blog:
On becoming a web artisan
Dec 07, 2016 @ 12:20:39

The O'Reilly Web Programming blog recently posted an interview with Matt Stauffer, the author of their recently published Laravel: Up & Running book. In the interview Matt talks about becoming a "web artisan" and offers some advice you could apply to your own development work.

I recently asked Matt Stauffer, Partner and Technical Director at Tighten Co. to discuss his work with the Laravel community, including what makes the PHP framework great for rapid application development and how it interoperates with new and emerging frontend tooling. Matt is also the author of Laravel: Up and Running, which O'Reilly published in November 2016.

Matt answers questions about the Laravel framework (why it's for "web artisans"), using it for prototyping, upcoming features he's excited about and advice he has for those just starting out in web development. Check out the full post for the answers to these and other questions.

tagged: interview mattstauffer oreilly laravel questions

Link: https://www.oreilly.com/ideas/on-becoming-a-web-artisan

TutsPlus.com:
Upgrading Your Linux Server to PHP 7.0
Dec 07, 2016 @ 11:47:25

The TutsPlus.com site has a new tutorial posted showing you how to upgrade your Linux server to run PHP 7.0, the latest major release of the PHP language.

PHP 7 was released last December. Once you've tested your code locally to run on it, it's time to upgrade your production server. Generally, I found that most of my sites run well on it.

However, I suspect that not many sites have upgraded yet. It's often safer and easier to stay on older releases. [...] But PHP 7 has now been out for nearly a year.

In today's episode, I'll walk you through my recommended approach to upgrading to PHP 7 on Ubuntu 14.x and resolving problems with PHPMyAdmin, which a lot of early upgraders ran into.

He starts by helping you identify any customizations that you might have related to PHP 5, specifically related to configuration options. He then provides the commands to remove PHP 5 packages from the system and add in the "ondrej/php" PPA for apt-get as the source for the PHP 7 packages. After a quick apt-get cleanup, he includes the commands to install the "php7" packages, enable a few extra modules and getting phpMyAdmin back up and in working order.

tagged: upgrade server php7 php5 ppa aptget phpmyadmin tutorial

Link: https://code.tutsplus.com/tutorials/upgrading-your-linux-server-to-php-7--cms-27583

Laravel News:
Route improvements are coming to Laravel 5.4
Dec 07, 2016 @ 10:12:31

The Laravel News site has a quick new post about some routing improvements that are coming in the next larger release of the framework , Laravel v5.4:

As Laravel 5.4 development continues, two new improvements are coming to your routes, better route caching for large applications and fluently registering routes.

The route caching updates will help performance with larger applications, reducing the parsing time required to locate and push a request to the right location. The "fluent" route improvements basically allow for the definition of some things, like middleware or route names, as a part of the route definition rather than after the fact. Examples of this are included in the post.

tagged: laravel routing improvement v54 cache fluent registration

Link: https://laravel-news.com/route-improvements

SitePoint PHP Blog:
The Delicious Evils of PHP
Dec 07, 2016 @ 09:50:49

On the SitePoint PHP blog Christopher Pitt is back with another interesting article, this time talking about two "delicious evils of PHP" - the eval and exec functionality.

I want to look at two PHP functions: eval and exec. They’re so often thrown under the sensible-developers-never-use-these bus that I sometimes wonder how many awesome applications we miss out on.

Like every other function in the standard library, these have their uses. They can be abused. Their danger lies in the amount of flexibility and power they offer even the most novice of developers. Let me show you some of the ways I’ve seen these used, and then we can talk about safety precautions and moderation.

He then talks about some of the "interesting" things you can do with these two pieces of functionality including:

  • Dynamic Class Creation
  • [Creating] Domain Specific Languages
  • Parallelism (with exec)

He ends the post with some advice how to avoid issues with the topics he's mentioned and how to "stay safe" while still using these two dangerous pieces of functionality.

tagged: evils language eval exec dynamic class dsl parallelism tutorial safe

Link: https://www.sitepoint.com/the-delicious-evils-of-php/

Community News:
Recent posts from PHP Quickfix (12.07.2016)
Dec 07, 2016 @ 08:05:02

Recent posts from the PHP Quickfix site:

tagged:

Link: