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

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

SitePoint Web Blog:
Please: Automated CMS and Framework Installs in Vagrant
May 25, 2016 @ 10:29:08

On the SitePoint.com site's "Web" category they're posted a tutorial showing off an interesting piece of software that helps make automated installs of CMS/frameworks easy: a simple bash script tool called Please.

If you’re a web developer, possibly one of your most boring and repetitive tasks is the configuration of the basic setup for every new project. Configuring your my-project.dev domain, creating the database, installing WordPress (or any other CMS/Framework) for the thousandth time: you already know how to do it. What if you could automate all of that?

Well, actually, you can. Please is a simple bash script that helps to automate the installations of many CMSs and Frameworks by configuring them automatically into your Vagrant box, adding a development domain name into your host file, and even a database if needed.

They start off by helping you get a Vagrant box up and running to use for the Please handling. You then clone the Please repository locally and can use the command line tool to set up the process for multiple CMS/framework types including WordPress, Laravel and React. There's also a section covering the creation of your own environment if you need something more custom. Please is currently in beta at the time of this post so be aware that there may still be issues that need resolving before it becomes stable.

tagged: please automated installation tool commandline cms framework vagrant

Link: https://www.sitepoint.com/please-automated-cms-and-framework-installs-in-vagrant/

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - CLI Example
Apr 07, 2016 @ 10:43:51

Loïc Faugeron has posted another in his "ultimate guide" series of posts around components in the Symfony framework. In this latest post he gives an example of using the command line component with the Console component.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory.

Finally we've started to put all this knowledge in practice by creating a "fortune" project with: an endpoint that allows us to submit new fortunes, a page that lists all fortunes. In this article, we're going to continue the "fortune" project by creating a command that prints the last fortune.

He walks through the use of an example repository as a base and shows:

  • the creation of the command class
  • the matching tests to ensure it's working correctly
  • building out the logic to pull in the latest fortunes

They enter the fortunes via the web interface and use the command line to output them as as simple text.

tagged: ultimate developer guide symfony commandline cli example tutorial series

Link: https://gnugat.github.io/2016/04/06/ultimate-symfony-cli-example.html

Richard Melo:
Run legacy PHP applications from command line
Feb 15, 2016 @ 11:55:49

Richard Melo has a post to his site sharing some helpful advice about running legacy PHP applications from the command line making use of the Symfony Console component to handle some of the heavy CLI duties.

Imagine that you already have a trustfully application that you have been running for a while, but there is a couple of common patterns that make you consider that you need a command line interface (CLI) for your application. [...] So, how do we do this? especially without reinventing the well?

He starts off with an example of the problem, having a bit of a legacy application that needs to take in data (in this case JSON) and handle it would requiring a form submission. He makes use of the Console component to wrap this functionality inside a command and take a JSON file as input. He includes the example code needed to make this simple setup including the Command class itself and a small "bootstrap" command line script to do the actual command execution. The post ends with an example of the command you'd use to run the script and push in the JSON contents.

tagged: commandline symfony console component legacy wrapper introduction tutorial

Link: http://rjsmelo.com/blog/2016/01/19/run-legacy-php-applications-from-command-line/

Geert Eltink:
Zend-Expressive Console CLI Commands
Feb 12, 2016 @ 11:21:15

In a new post to his site Geert Eltink shares how he added console command support to Zend Expressive, a PSR-7 framework from Zend that recently hit it's v1.0 mark.

zend-expressive does not come out of the box with a console for handling cli commands. However it's easy to add this and make full use of the container and its dependencies.

He uses the Symfony console component to handle most of the "heavy lifting" with the command line interaction, pulled in via Composer. He shows the process for getting the component installed and how to create the "bootstrap" file needed to build an instance of the Application class. He follows this with a simple "greeting" command including the configuration to add a few arguments and output the simple "Hello" message. He then creates the functionality to wire it in to the Zend Expressive application and gives an example of it in use.

tagged: zend expressive framework console command commandline cli tutorial symfony component

Link: https://xtreamwayz.com/blog/2016-02-07-zend-expressive-console-cli-commands

WP REST API: Setting Up and Using Basic Authentication
Jan 08, 2016 @ 11:37:58

On the NetTuts.com site there's a tutorial posted showing you how to set up and use basic authentication in the WordPress REST API. This is part two in their series introducing the WordPress REST API.

In the introductory part of this series, we had a quick refresher on REST architecture and how it can help us create better applications. [...] In the current part of the series, we will set up a basic authentication protocol on the server to send authenticated requests to perform various tasks through the REST API.

They talk about the methods that are available for authentication and how to configure your server and WordPress instance to use it. From there they show how to make authenticated requests to the API using various tools:

  • Postman
  • a Javascript framework (jQuery)
  • the command line via curl
  • using the WP HTTP API

Example code and screenshots are provided for each (where appropriate) helping to ensure you're up and working quickly.

tagged: wordpress rest api tutorial authentication basic postman javascript commandline

Link: http://code.tutsplus.com/tutorials/wp-rest-api-setting-up-and-using-basic-authentication--cms-24762