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

How to configure PHPStorm to use PHP-CS-Fixer
Apr 25, 2017 @ 10:47:46

On the Hackernoon site there's a recent tutorial showing you how to hook the PHP-CS-Fixer tool into PhpStorm for easy execution during development rather than after.

The PHPStorm IDE by JetBrains is probably one of my favorite editors. It has its flaws (constant indexing…) but overall its a great tool for me. However, my focus today is not on PHPStorm per say but rather how to add the awesome functionality of using project page. Depending on your platform you will need to make some decisions, namely how you configure the rules of PHP-CS-Fixer. I am currently on Windows but I will try to make sure these instructions work in both *nix and Windows environments.

He then walks you through some prerequisites (both pieces of software installed basically) and the decisions to make based on your platform. He then provides screenshots and descriptions showing where to go in the PhpStorm IDE to add the PHP-CS-Fixer as a new "Tool", the working directory to use and how to set up a keymap to execute the tool. He includes an example of the output when things are correctly configured and working together.

tagged: configure phpstorm phpcs phpcsfixer tool tutorial install combine setup ide

Link: https://hackernoon.com/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f

Amazon Web Services:
PHP application logging with Amazon CloudWatch Logs and Monolog
Apr 24, 2017 @ 09:46:47

On the Amazon Web Services blog there's a new post showing you how to use the Monolog logging library and a custom AWS extension to ship your logs to Amazon CloudWatch quickly and easily.

Logging and information debugging can be approached from a multitude of different angles. Whether you use an application framework or coding from scratch it’s always comforting to have familiar components and tools across different projects. In our examples today, I am going to enable Amazon CloudWatch Logs logging with a PHP application. To accomplish this, I wanted to use an existing solution that is both already popular and well used, and that is standards compliant. For these reasons, we are going to use the open source log library, PHP Monolog (https://github.com/Seldaek/monolog).

They start by introducing the Monolog library for those not familiar with it and how it relates to the PSR-3 standard. The ultimate goal with their implementation is to allow for the logs to be shipped to CloudWatch and implement some alerting around them. The tutorial then kicks in and they show you how to use Composer to install Monolog and an add-on to interface with CloudWatch. Code is provided to set up the initial logger and how to have it to log messages to different places. They then move over to CloudWatch and define a filter for the JSON data to find successful logins to your application. They also show how to use this same functionality in a Laravel application, contained in a test route.

tagged: aws amazon logging cloudwatch monolog tutorial install usage filter

Link: https://aws.amazon.com/blogs/developer/php-application-logging-with-amazon-cloudwatch-logs-and-monolog/

Zend Framework Blog:
Develop Expressive Applications Rapidly Using CLI Tooling
Apr 12, 2017 @ 09:54:05

On the Zend Framework blog Matthew Weier O'Phinney has posted a tutorial showing off some of the Expressive command line functionality that can help you rapidly develop applications using the Zend Expressive framework.

First impressions matter, particularly when you start using a new framework. As such, we're striving to improve your first tasks with Expressive. With the 2.0 release, we provided several migration tools, as well as tooling for creating, registering, and deregistering middleware modules. Each was shipped as a separate script, with little unification between them.

Today, we've pushed a unified script, expressive, which provides access to all the migration tooling, module tooling, and new tooling to help you create http-interop middleware. Our hope is to make your first few minutes with Expressive a bit easier, so you can start writing powerful applications.

The post starts with the Composer commands to create a new Expressive project and to pull in the "zendframework/zend-expressive-tooling" package to add the CLI tools to the project. It then talks briefly about what functionality the tools bring and helps you use them to create your first module, populating out the directories and files required. Next up is the creation of the middleware for a "list" action and what the resulting code ends up being. They end the post by pointing out that this is just a start to the ultimate functionality of this tool and are open to requests for new commands to add in future releases.

tagged: zendexpressive application tooling commandline expressive tutorial install

Link: https://framework.zend.com/blog/2017-04-11-expressive-tooling.html

Sameer Borate:
Accessing Google Page Insights in PHP
Mar 21, 2017 @ 09:45:12

On his site today Sameer Borate shares a tutorial showing you how to access Google Insights data via your PHP application with the help of the dsentker/phpinsights package.

Google Page Insights is a required tool to have when analyzing the speed and usability of your site. As you may know these metrics influence how google ranks your page in search results. If you frequently make changes to your web site designs than it becomes mandatory to check the metrics after each change to make sure that the design changes has not affected the score in any negative way. If you have many pages to test than manual testing can quickly become cumbersome.

Thankfully there are libraries that you can use to automate this process. Once such is given in this post which allows you to get Google Page Insight metrics using PHP.

He then walks you through the installation of the package (via Composer) and how to use it, along with your Google API key, to fetch the information for a given URL. You can get information for different environments (desktop vs mobile) and even a screenshot of the page that's under test. He ends the post with a helpful hint for those that might get a certificate error when making the request and how to fix it.

tagged: google insights data tutorial package install usage

Link: http://www.codediesel.com/api/accessing-google-page-insights-php/

SitePoint PHP Blog:
The Android Elephpant - Laravel on your Android Phone?
Mar 14, 2017 @ 13:06:05

On the SitePoint PHP blog there's a new tutorial posted with an interesting idea for the use of PHP - running it on an Android phone (a Laravel application specifically).

It was not that long ago that Christopher Pitt wrote an excellent article about writing and running PHP code on an iPad. After reading it, I thought to myself "It would be really cool to do the same on Android": being able to write and edit code on the fly, for example while traveling, and not having to take the laptop everywhere. So I’ve decided to do some research and see what I could come up with.

For this article, you can use any type of Android device. I’ve done it on my phone, but an Android tablet with a Bluetooth keyboard would probably be the ideal setup.

Using the Termux application and using it to install various packages for both development and PHP usage. They also install Vim, Git and Composer to make package management easier. Once the environment is installed it moves on to the Laravel installation (that works just fine), installing SQLite for the database and building out the user authentication and authorization handling with Laravel's "make:auth" artisan command.

tagged: android tutorial phone laravel install configuration

Link: https://www.sitepoint.com/android-elephpant-laravel-android-phone/

Laravel News:
Installing Laravel in a Subfolder? Hide your .env file.
Mar 06, 2017 @ 09:42:59

On the Laravel News site they've posted an article with some reminders about installing Laravel in a subfolder including "hiding" your .env file.

If you are new to Laravel you might not be familiar with its directory structure and the reasons why it’s setup the way it is. If you look at the main repository it’s setup like this, and the documentation covers what each of these folders handles.

What is important here is the “public” folder. That is the ONLY directory you want to be exposed through the web. Everything else should be outside of your web root, this way people can’t access any of your important files through the browser.

He gives an example of an instance where a site was in a subfolder and, just by changing the URL, he was able to locate (and view!) the .env file complete with sensitive information. The rest of the post gives instructions on installing it in a subfolder, moving around a few folders and updating the front controller to change the autoload and bootstrap locations.

tagged: laravel subfolder sensitive data install tutorial

Link: https://laravel-news.com/subfolder-install

Zend Framework Blog:
PHP and SQL Server for Linux
Feb 15, 2017 @ 11:21:52

The Zend Framework blog has a new post from Enrico Zimuel talking about the use of SQL Server for Linux from inside a PHP-based application. This makes use of the preview release of SQL Server for Linux directly from Microsoft.

This week we tested the public preview of Microsoft SQL Server for Linux using PHP 7 with our component zendframework/zend-db.

Microsoft announced the availability of a public preview of SQL Server for Linux on the 16th of November, 2016. [...] Moreover, the performance of the new DBMS seems to be very impressive. Microsoft published a case study with 1.2 million requests per second with In-Memory OLTP on a single commodity server.

The tutorial shows you how to get the SQL Server software installed on a Ubuntu-based system and install it via apt-get. They also show how to install the command line tool for SQL Server and get the msodbcsql driver needed to make the connection. Finally they show how to set up the driver with PHP 7 (via PDO) and running the Zend/Db integration tests using a Vagrant-created and configured VM instance.

tagged: sqlserver linux tutorial php7 install configure vagrant microsoft

Link: https://framework.zend.com/blog/2017-02-14-php-sql-server-linux.html

Rob Allen:
Using Phive to manage PHPUnit
Jan 05, 2017 @ 10:36:41

Rob Allen has a new post to his site sharing the work he's done to get PHPUnit managed with Phive, an "installation and verification environment" that is used in the installation of Phar archives.

I recently came across the Phive project and have had a play with it. Phive is part of phar.io and is intended to manage development tools such as PHPUnit in preference to using Composer's dev dependencies. The main advantages of Phive are that it uses the phar file of the tool and only keeps one copy of each version rather than downloading a new copy into each project.

He starts off talking briefly about how the tool works and what it's doing behind the scenes to download the phar archives requested. He shows how to define a target directory, install for global use and explains how GPG signatures work into the installation process.

tagged: phive install phar manage gpg signature verification environment phpunit tutorial

Link: https://akrabat.com/using-phive-to-manage-phpunit/

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

Jordi Boggiano:
PHP Versions Stats - 2016.2 Edition
Nov 18, 2016 @ 11:17:40

In his latest post Jordi Boggiano (of the Composer project) has released his PHP usage statistics for the second half of 2016 based on the information gathered during Composer installations.

It's stats o'clock! See 2014, 2015 and 2016.1 for previous similar posts.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last 28 days for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

He compares them to the statistics from May 2016 showing some interesting but not unexpected changes, mostly in the growth of PHP 7+ versions. He shares a few of his own observations of the results and encourages library authors to start focusing on PHP 7 functionality rather than 5.5/5.6 compatibility. He also shares a secondary data set - the PHP versions that libraries require that, surprisingly, is moving a lot slower than the actual PHP version adoption.

tagged: version language statistics 2016 requirement composer install results

Link: https://seld.be/notes/php-versions-stats-2016-2-edition