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

What Is WP-CLI? A Beginner’s Guide
May 18, 2017 @ 10:35:31

The TutsPlus.com site has posted a new tutorial introducing you to the WordPress command line tool, the WP-CLI.

WP-CLI has been around for quite some time now (circa 2011) and has steadily gained momentum in the WordPress developer community. But what is it exactly, and how can you use it in your WordPress workflow?

The idea behind WP-CLI is that it allows you to interact with, and manage, WordPress sites via a command line interface. According to the official documentation, it's a command line alternative to using the traditional WordPress admin user interface.

They starts by explaining some of what the tool can do and help you get it installed either manually (on Mac or Windows) or more automatically for the DesktopServer users out there. The tutorial then goes through the basics of using the wp command line tool including getting a listing of current settings, showing the version installed and getting a list of currently installed plugins and themes. It also shows how to install new plugins, list posts, pages and comments currently in the system. The post ends with some additional resources where you can get more information about the WP-CLI tool and its features.

tagged: wordpress wpcli tool commandline introduction tutorial

Link: https://code.tutsplus.com/tutorials/what-is-wp-cli-a-beginners-guide--cms-28649

Supercharge Your Laravel Tinker Workflow
May 11, 2017 @ 09:37:19

On the Tighten.co blog they have a new post that aims to help you get the most out of the Laravel command line tool's (artisan) tinker command.

Laravel's command line tool is called "Artisan," and it comes with a few powerful features out of the box. Tinker, accessed via php artisan tinker, is arguably my favorite Artisan command. It speeds up my workflow and allows me to interact with my application in ways I would have never thought possible.

Tinker is a REPL (read-eval-print loop). A REPL gives you a prompt that allows you to interact with your application using your language's native syntax (in this case, PHP) in a command-line style.

The post then walks through some of the "hidden features" this command line tool offers including:

  • basic usage to call Laravel code (like getting all posts using Post::all)
  • a more interactive version of dd(), a debugging tool
  • improving speed on a Laravel Dusk testing workflow
  • direct access to the PHP docs

The post ends with a few other smaller things this helpful tool can do like showing a stack trace, listing the command history and re-throwing the last exception.

tagged: laravel workflow tinker commandline tool artisan tutorial

Link: https://blog.tighten.co/supercharge-your-laravel-tinker-workflow

Derick Rethans:
15 years of Xdebug
May 10, 2017 @ 10:27:14

In a recent post the fifteenth anniversary of the XDebug PHP debugging tool was celebrated and lead developer Derick Rethans was presented with several tokens of appreciation from the PHP community. In this new post to his site he shares the experience (it was a surprise after all) from his perspective and thanks those involved.

This article was going to be about some upcoming features in the 2.6 release. Or rather, I was hoping to announce at least a beta release of Xdebug 2.6. Unfortunately, I couldn't find enough time to work on all the issues that I wanted, although I've made a little progress.

What I can write about, is a little mystery.

He talks about the initial invite from James Titcumb to meet him at his favorite whisky store and the eight special bottles that the community purchased to show their appreciation for his hard fifteen years of work on this invaluable tool. He lists out the types for those interested and some of the messages from contributors showing their appreciation. He thanks all of those involved.

And on the Xdebug front, there are plenty of bugs to fix, features to add for Xdebug 2.6, and undoubtedly Dmitry will be "breaking" some things in PHP 7.2 that I need to support in Xdebug as well.
tagged: fifteen years anniversary derickrethans xdebug debugging tool project whiskey

Link: https://derickrethans.nl/xdebug-15.html

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

Building maintainable PHP apps using Composer
Apr 03, 2017 @ 12:14:02

The BugSnag blog has a post by guest author Graham Campbell sharing some best practices when using Composer in your PHP applications. It's written mainly for those that haven't used Composer much yet and want to get started quickly and easily.

Composer has made big waves in the PHP community in recent years. Thanks to Composer’s creators, Jordi Boggiano and Nils Adermann, Composer has become the absolute backbone of PHP’s package infrastructure today.

In this blog post, we shall be introducing Composer, from the ground up. We will see what packages are, how they should be versioned, and how to install them into your application. Learn about Composer and never look back!

He starts out by defining what a package is in the world of Composer and how it differs from a "library". He then briefly touches on the early days of the tool before showing how to get it installed and creating your first "composer.json" configuration file. He then gets into one of the more tricky subjects when dealing with Composer and packages - versioning. Finally he covers a few of his suggested best practices when using Composer including defining your own package installation constraints and how the autoloading works to your benefit.

tagged: composer bestpractices introduction configuration package library tool

Link: https://blog.bugsnag.com/best-practices-using-composer/

Zend Framework Blog:
Migrating to Expressive 2.0
Mar 14, 2017 @ 12:36:17

The Zend Framework blog has a tutorial they've posted showing you how to migrate up to Zend Expressive v2.0 from a v1.x application and some of the things that could break along the way.

Last week, we released Expressive 2. A new major version implies breaking changes, which often poses a problem when migrating. That said, we did a lot of work behind the scenes to try and ensure that migrations can happen without too much effort, including providing migration tools to ease the transition.

In this tutorial, we will detail migrating an existing Expressive application from version 1 to version 2.

Using this repository for a testbed, they walk through the steps for the update:

  • Creating a migration branch
  • Updating dependencies
  • using the zendframework/zend-expressive-tooling to aid in the migration
  • scanning your code to find possible breaking locations
  • moving over to the programmatic pipeline structure

They also include some bonus information covering self-invoking functions, the zend-config-aggregator and development mode. The post ends with the updates you'll need to make to middleware to implement the http-interop/http-middleware MiddlewareInterface.

tagged: zendframework zendexpressive v2 migration guide tool

Link: https://framework.zend.com/blog/2017-03-13-expressive-2-migration.html

Community News:
Exakat - Static analysis tools for PHP
Feb 27, 2017 @ 14:25:25

On the Exakat GitHub account Damien Seguy has put together a pretty complete list of static analyzers you can use for your PHP applications.

The list is broken down into the types of scanners:

  • Bugs finders
  • Coding standards
  • DIY
  • Fixers
  • Metrics
  • SaaS
  • Misc

Each section includes a good list of tools and links to each of them (usually just to other GitHub repositories but some go to actual project pages). There's a lot of them to look through but be careful to evaluate the current state of the project. Just because it's linked here doesn't mean it's a complete tool.

tagged: static scanner tool language bug standard metrics saas list

Link: https://github.com/exakat/php-static-analysis-tools

SitePoint PHP Blog:
Testing Frenzy – Can We BDD Test the Units?
Jan 30, 2017 @ 12:50:10

On the SitePoint PHP blog editor Bruno Skvorc has written up a tutorial about using the Peridot tool to do BDD style testing but on the units of code rather than the behavior of your integrated application (your business logic).

We’ve done our share of testing posts here at SitePoint, with more coming soon, but I wanted to show you a relatively new testing tool I found that caught my attention because of how unconventional it seemed.

Peridot is a BDD testing framework (so behavior driven testing) but for your units of code – not your business logic. Wait, what? Yes.

He gives an example of the test structure and how a similar kind of test would reduce down to assertions evaluating your units of code. He also includes an example of Peridot's human-friendly output for both passing and failing tests. He goes on to talk about the concurrency the tool allows, the feature to focus on/skip certain tests, use events and plugins, and output a code coverage report. Several more features are also discussed including custom scopes and the ability to define custom DSL definitions you might find easier to work with in your testing.

tagged: bdd test unittest peridot tool package tutorial introduction

Link: https://www.sitepoint.com/testing-frenzy-can-we-bdd-test-the-units/

Master Zend Framework:
How To Generate Dependency Configuration's Easily with ConfigDumper
Jan 24, 2017 @ 13:45:26

The Master Zend Framework site has a new tutorial posted showing how to generate dependency configurations easily with the help of the ConfigDumper component is a Zend Framework based application.

Want to save time generating dependency configuration files for your Zend ServiceManager dependencies? In today's tutorial, I'll show you how, by using ConfigDumper, available in ServiceManager 3.2.0.

In the previous tutorial, we saw how to use FactoryCreator’s command-line tool, generate-factory-for-class, to quickly and easily create factories for classes.

In this, the follow-up tutorial, we’re going to see how to use generate-deps-for-config-factory, the command-line tool for ConfigDumper, to save time when generating dependency configuration files for use with our classes.

He starts by helping you get the correct version of the ServiceManager installed (3.2.0) and provides an overview of the generate-deps-for-config-factory tool. He moves on to a simple example using one of the included classes (the PingAction) and calls the generator with an example of the results. From there he includes a more complex example using the HomePageAction as its source. He points out that this tool doesn't work for every class and gives an example of a failure around a missing type hint. The post wraps up with a look at the ConfigAbstractFactory and how you can use the configurations that result from using the generation tool.

tagged: zendframework dependency configuration configdumper tool servicemanager tutorial

Link: http://www.masterzendframework.com/dependency-config-generation-with-configdumper/

Laravel News:
Checking the Code Complexity of your App
Jan 11, 2017 @ 11:52:58

On the Laravel News site there's an article posted showing you how to determine the complexity of your application using the phploc tool from Sebastian Bergmann.

Yesterday, Taylor made a post comparing the code complexity between Laravel and other frameworks. The tool he used to generate these reports is called phploc and it’s very easy to run on your own code base.

I decided as a means of comparison I would run that on the codebase for this site and just see what the results are.

The tutorial walks you through the installation of the tool (as a globally installed Composer package), how to execute it and what the results look like. These results include a lot of data including:

  • Average Class Length
  • Average Complexity per LLOC
  • (Use of) Global Constants
  • (Number of) Namespaces

phploc is useful for getting the overall numbers but he wanted something a bit more specific. For that he chose the PhpMetrics package that allows for deeper introspection into files and classes in your code to locate the complexity and find spots for refactoring.

tagged: code complexity tool phploc phpmetrics example composer tutorial

Link: https://laravel-news.com/code-complexity-tools