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

Master Zend Framework:
Create Modules and Middleware with Command-Line Tooling Support
Jun 12, 2017 @ 10:44:05

The Master Zend Framework site has posted a new tutorial covering an aspect of the Zend Expressive project that doesn't seem to get enough coverage: the tooling included with the skeleton application.

For the longest time, Zend Framework hasn't had the strongest command-line tooling and scaffolding support. In stark contrast, other frameworks — especially Laravel, and its excellent Artisan command — have had far stronger tooling support and as a result have been far easier to build projects with. However, that's all changed!

Since the release of Zend Expressive Skeleton 2.0.2, Zend Expressive's command-line tooling support has been rapidly developing. It's provided through a package called, aptly, Zend Expressive Tooling.

The post briefly describes what features the tooling brings and then gets right into the installation process (via Composer). The tutorial then walks you through the commands it provides to create middleware, modules and handle migration to latest versions of the framework. The module and middleware topics are then covered more in-depth, showing code and commands required.

tagged: zendexpressive tooling middleware module commandline tutorial

Link: http://www.masterzendframework.com/tooling/create-modules-and-middleware/

SitePoint PHP Blog:
Re-Introducing Symfony Console – CLI PHP for the Uninitiated!
May 25, 2017 @ 11:38:02

The SitePoint PHP blog has posted a tutorial from author Claudio Ribeiro that wants to re-introduce you to the Symfony Console package, a component of the larger Symfony framework that makes it easier to create and work with command-line PHP scripts.

As software developers, we often feel the need to resort to command line tools. These kinds of tools are helpful when we need to do a sort of recurring task like migrating data, performing imports, or creating cron jobs.

The Symfony Console component tool provides us with a simple framework to create our own command line tools. Unlike many components in Symfony, this is a standalone package and is used by the likes of Laravel‘s Artisan and many other famous PHP packages.

The tutorial then walks you through the installation process, via Composer, and the creation of a new command. With this simple base created, he then adds in actual functionality, building out a command to hash and verify a password string. They show how to use the command and an example of its output. Next up, he creates another command example, this time verifying the password hash provided as an argument. The tutorial wraps up with a look at testing your console comamnds with PHPUnit tests via the included CommandTester functionality.

tagged: symfony console commandline cli package component tutorial introduction

Link: https://www.sitepoint.com/re-introducing-symfony-console-cli-php-uninitiated/

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

Rob Allen:
Autocomplete Composer script names on the command line
May 15, 2017 @ 09:43:22

Rob Allen has a quick new post with a handy script you can use to auto-complete Composer script names on the command line (for bash).

As I add more and more of my own script targets to my composer.json files, I find that it would be helpful to have tab autocomplete in bash. I asked on Twitter and didn't get an immediate solution and as I had already done something similar for Phing, I rolled up my sleeves and wrote my own.

He created the bash completion file where Bash could locate it (a special "bash_completion.d" directory). He includes the code you'll need to have in the bash script and briefly explains how each line works. He also includes an example of the output showing how the script catches both the built-in and custom commands as auto-complete options.

tagged: autocomplete composer script bash commandline tutorial

Link: https://akrabat.com/autocomplete-composer-script-names-on-the-command-line/

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

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

Delicious Brains Blog:
Scaling Laravel Using AWS Elastic Beanstalk Part 3: Setting up Elastic Beanst
Feb 07, 2017 @ 10:29:41

The Delicious Brains blog has posted the third part of their series covering the scaling of Laravel with AWS Beanstalk. In this latest article the walk through the setup of the Elastic Beanstalk application.

In my last article we set up the supporting services we would require for our Laravel app once we deploy it to the Elastic Beanstalk architecture. We created a VPC to keep our infrastructure secure, we created a MySQL database in RDS, and we set up ElastiCache for our Redis cache. So now that our Laravel app is decoupled and our supporting services are in place, it’s finally time to deploy our app to Elastic Beanstalk.

They start by talking about the Elastic Beanstalk environments and helping you get the application set up via the command line tool. Next up is the creation of the ebextensions directory and the matching YAML configurations for the EB settings. They provide an example of the contents` and explain what some of the configuration sets up. Finally they use the command line tool to issue the "create" command and build out the environment based on the configuration. The post wraps up with a bit about some configuration tweaks that could be made and optionally enabling HTTPS.

tagged: tutorial elastic beanstalk tutorial series part3 setup environment commandline

Link: https://deliciousbrains.com/scaling-laravel-using-aws-elastic-beanstalk-part-3-setting-elastic-beanstalk/

SitePoint PHP Blog:
How’d They Do It? PHPSnake: Detecting Keypresses
Oct 31, 2016 @ 15:14:23

The SitePoint PHP blog has a new tutorial posted from editor Bruno Skvorc looking at building a "snake" game purely with PHP and handling/catching keypresses.

At a recent conference in Bulgaria, there was a hackathon for which Andrew Carter created a PHP console version of the popular “snake” game. I thought it was a really interesting concept, and since Andrew has a history of using PHP for weird things, I figured I’d demystify and explain how it was done.

The original repository is here, but we’ll build a version of it from scratch in this series so no need to clone it.

They start by defining some of the requirements for the game, including that it is to be CLI based with no browser functionality allowed. With those defined, they get into the code, starting with some of the "boilerplate" code to work with the command line environment, handle output and reading in characters as keys are pressed. The tutorial then gets into mapping the snakes to "directions" do that the keypresses would make the snake go up, down, left or right.

tagged: phpsnake snake detect keypress tutorial commandline

Link: https://www.sitepoint.com/howd-they-do-it-phpsnake-detecting-keypresses/

Symfony Finland:
PHP development with Windows Subsystem for Linux (WSL)
Aug 08, 2016 @ 09:48:19

On the Symfony Finland site there's a new article posted talking about the use of the Windows subsystem for Linux, an environment that allows for the execution of Linux binaries in a Windows environment.

Windows has always been somewhat of an oddball when it comes to PHP development. In the past years it has lost out on developer mindshare to UNIX-like Operating Systems like Linux and macOS.

With the release of Windows 10 Anniversary Update in August 2016 Microsoft now offers an interesting option for PHP development in the Windows environment: The Windows Subsystem for Linux (WSL). The Windows Subsystem for Linux allows the execution of Linux binaries in Windows 10. The feature is not enabled by default and is targeted for developers.

They show you how to get into the Linux-compatible shell on your Windows system after enabling it in your System Settings. From there, he says, it's basically like working in a Linux-based server and includes some of the actions he took (including installing PHP 7, Symfony and Composer). He also shows the integration the environment has back with the Windows system including access to local drives (but that there's still some tricky bits involved in using them).

tagged: development windows subsystem linux commandline install symfony environment

Link: https://www.symfony.fi/entry/php-development-with-windows-subsystem-for-linux-wsl

Liip Blog:
Let’s debug in Drupal 8 !
Jun 20, 2016 @ 09:23:37

In a new post to the Liip blog Karine Chor shares some helpful Drupal 8 debugging tips and things you can do to determine what you code is doing "under the covers".

It has been nearly 7 months since Drupal 8 first release and as a developer, I am still in the learning process. It can be hard sometimes to know what is going wrong with your code and how to solve it. I will tell you about few things to know on how to develop and debug Drupal 8 projects and continue learning, learning and learning !

Her tips cover topics like:

  • Disabling cache
  • Displaying errors
  • Creating log messages
  • Debugging Twig templates
  • Profiling pages

The post ends with a section covering use of the the Drupal command line tool to provide even more real-time debugging functionality.

tagged: debugging drupal8 commandline cache error log twig profiler tutorial

Link: https://blog.liip.ch/archive/2016/06/20/lets-debug-drupal-8.html