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/

Zend Framework Blog:
Leverage Zend Component Plugin Managers in Expressive
May 19, 2017 @ 09:58:15

The Zend Framework blog has a new post from project lead Matthew Weier O'Phinney showing how you can use plugin managers in Expressive and how it can be used to integrate other components.

With the release of Expressive 2, one of the key stories was the ability to require ZF components within Expressive, and have their dependencies auto-wired into your application courtesy of the component installer.

However, we recently had a user in our Slack channel (need an invite?) indicating they were having issues with usage of custom validators, filters, and input filters. After a <a href=https://discourse.zendframework.com/t/validatormanager-not-calling-custom-validator-factory/109">more thorough writeup on our forums, I realized we'd missed something important when making these integrations, and set out to solve it.

The article then starts with the problem that they're trying to solve, mostly around configuration handling. The solution involved some work done on various packages (like zend-log, zend-filter and zend-form) to make the configuration loading a bit more automated (and with fallback handling).

tagged: zendexpressive module component manager update package

Link: https://framework.zend.com/blog/2017-05-18-plugin-managers.html

Liip Blog:
Using the new Drupal 8 Migration API / Module
May 06, 2016 @ 10:14:23

On the Liip blog there's a post from Jon Minder talking about the new Drupal 8 migration API/module and includes a guide to get you started using it in your Drupal application.

We at Liip AG believe, that the migration API is the best and most efficient way to import data into Drupal. [...] The Migrate 8 module in core is only an API. There is no user interface. This makes it difficult for new developer to start with Migrate 8.

I suggest you, to install the [several] extension modules right away before you start developing if you want to realize the full potential of migrate.

The post starts with a list of reasons they see to use the migration module over other methods including the fact that it's sponsored and supported by Acquia. He provides a list of modules to install before getting started with Migrate and links to a GitHub repository if you'd like a "quickstart" environment to follow his examples. He then compares the previous version (from Drupal 7) of the migration handling with the newer Drupal 8 functionality, most notably the change over to YAML configuration rather than PHP code. He helps you understand the structure of these files and gives an example. He shows how to run the migration, gives a more advanced JSON source example and mentions the included process plugin.

tagged: drupal8 migrate module api drupal7 example yaml configuration

Link: https://blog.liip.ch/archive/2016/05/04/using-the-new-drupal-8-migration-api-module.html

Michelangelo van Dam:
Installing PHP 7 on OS X Yosemite
Dec 07, 2015 @ 09:40:34

Michelangelo van Dam has a post to his site, now that PHP 7 is released, showing you how to get it installed on OSX (Yosemite) for your local development.

Yesterday was the release of PHP7.0.0 and I wanted to have it on my mac as fast as possible. Since I'm still using Mac OS X Yosemite I will post here the steps to upgrade my platform, it might be useful for you too.

He starts with the requirements needed for the installation including XCode to be able to compile the PHP from scratch and the latest download of PHP 7 from php.net. He then talks about the benefits of compiling your own installation and shares a script that he uses to compile the PHP version he wants (based on a command line option). Once this is run the typical make and make install are executed and, if all goes well, your output for a /opt/php7/bin/php -v will look the same as his.

tagged: install php7 osx yosemite script compile custom module

Link: http://www.dragonbe.com/2015/12/installing-php-7-on-os-x-yosemite.html

Understand Overriding in Magento: Controllers
Jul 24, 2015 @ 11:19:45

The NetTuts.com site has posted a tutorial (the third and last in their series) showing how to override controller handling in Magento. In the previous posts they showed how to override functionality related to the models and blocks (frontend layout elements).

In Magento, the controller is responsible for handling incoming requests, and it's a backbone of the Magento routing implementation. [...] As I said in the previous tutorial, it's never recommended to change core files directly, as it makes upgrading Magento really difficult. To avoid this, we should follow the standard way of making desired changes to core files: we should either use event observers or override core files with our custom module files. We'll discuss the overriding feature today.

You'll need to be familiar with custom module creation to be able to follow along (see here if not) but other than that they provide everything you'll need. They start by creating the files and folders needed for the custom module including:

  • Module XML definition (Envato_All.xml)
  • Module XML configuration
  • the Envato_Catalog_ProductController controller file (PHP)

The controller extends the pre-existing Product controller but the configuration definitions tell it ti use the "Envato" version instead.

tagged: magento overriding controller tutorial custom xml module

Link: http://code.tutsplus.com/tutorials/understand-overriding-in-magento-controllers--cms-23386

Lorna Mitchell:
Compiling PHP Extensions
Aug 29, 2014 @ 09:28:42

Lorna Mitchell has posted a quick guide to compiling PECL extensions to her site today. This is for those users on unix-based systems that might need to manually compile with some custom options (or may be working on your own extension and may just need to test it).

There are lots of reasons why you might like to compile your own PHP extensions. [...] I haven't seen a really approachable guide anywhere, we tend to speak of extensions in hushed tones, and actually it isn't particularly tricky so here is my quick how-to guide.

The process is relatively simple for those familiar with the command line and the steps involved in compiling software. There's some special PHP-only steps you'll have to take before compiling the code to make sure it's ready to be a PHP extension. Then it's up to the usual configure+make_make install to ensure the .so file is correctly generated.

tagged: compile extension tutorial phpize module

Link: http://www.lornajane.net/posts/2014/compiling-php-extensions

Master Zend Framework:
How to Use ZFTool Diagnostics To Ensure Your Modules Work
May 13, 2014 @ 10:55:19

The Master Zend Framework site has a new tutorial today showing you how to use the ZFTool diagnostics to make sure your modules are working correctly. The ZFTool is a stand-alone tool that can help with common tasks like working with application configuration and creating module and project skeletons.

Do you want to be sure that when you create Zend Framework 2 modules, that they’ll work in whatever environment they’re used in? At the very least, do you want a simple way for users to check, as well as something that’s self-documenting? If so, you’re in the right place. Last year, I gave a basic introduction to ZFTool, which is a command line tool to manage applications written in Zend Framework 2. [...] In addition to [the included diagnostic checks] we can write our own diagnostic checks, using the Success, Failure and Warning classes. So in today’s tutorial, I’m going to show how to add diagnostics support to a module.

He's broken the rest of the tutorial up into four other parts, each with the code or commands you'll need:

  • Add Diagnostics Support
  • The Diagnostics Function
  • Running Module Diagnostics
  • When Checks Fail

You can find out more about the ZFTool and its usage in with diagnostics in the official manual

tagged: zftool module diagnostic validate zendframework2

Link: http://www.masterzendframework.com/zftool-2/use-zftool-diagnostics-ensure-modules-work

Master Zend Framework:
Make Module Configs Cacheable with the ZF2 Factory Interface
Mar 07, 2014 @ 11:25:09

Matthew Setter has a new post today on the "Master Zend Framework" site looking at the use of caching for Zend Framework 2 module configurations.

For the longest time, I’ve been using closures in my Zend Framework 2 Modules Module class. I know they’re not always the best approach, but they’re not necessarily wrong either.

But after reviewing Gary Hockin’s recent talk at PHP Conference UK, I was reminded that outside of APC and OPCache, closures aren’t cacheable. [...] So in today’s tutorial, I’m going to show you a simple example of how to migrate from closures using [caching with Memcached, Redis and so on].

He starts with an example of the standard closure approach, returning an array from his "getServiceConfig" method with sub-array and object creation nested inside. He then refactors it to use the "FactoryInterface" to handle the configuration setup for the "delete form" handling.

tagged: module configuration cache zendframework2

Link: http://www.masterzendframework.com/tutorial/zf2-factory-interface-closure-migration

VG Tech:
Swagger Docs in ZF2 with Examples - Part 2: Swagger UI
Mar 06, 2014 @ 09:52:25

On the VG Tech blog, they've posted a follow-up to their previous post about using the Zend Framework 2 to generate Swagger documentation for an API. In this new post (part 2) they focus more on Swagger UI.

This blog post on Swagger UI is a follow-up on my recent post on Swagger annotation parsing in ZF2. If you’re not already set up with Swagger annotation parsing in you ZF2 app I recommend that you read part 1 first. In the last post we got ZF2 set up with annotation parsing and everything, and the only thing missing was Swagger UI for the neat presentation. I skipped that previously but today we’ll add the last piece.

This second part of the series uses a custom package to create a "SwaggerUI" module. There's a few file updates that need to be made to the configuration, but the rest is handled for you. In the end, the result will look something like this, showing endpoints and allow you to interact with the API directly through forms and sample calls.

tagged: swagger swaggerui tutorial series part2 package module

Link: http://tech.vg.no/2014/03/06/swagger-docs-in-zf2-with-examples-part-2-swagger-ui-2/

Kevin Schroeder:
Creating a module in Magento 2
Dec 12, 2013 @ 09:15:40

Kevin Schroeder has posted a step-by-step guide to his site today about creating a module for Magento in the first of a series of posts about Magento.

I believe that one of the best ways to learn something is to write out what it is you are learning. This forces you to think through the concepts and determine how to explain them to others. In doing so you are forced to use terms that are familiar to describe this new thing. This helps to solidify the concepts in your own mind, making it easier to remember. But still, there are three caveats: Magento 2 is not out yet, I'm learning as I write and what I share is what I see (my interpretation).

He talks about some of the differences between Magento 1 and 2 including:

  • The lack of code pools
  • Discovery XML files are in a different location
  • A different parser for these XML files

With all of this configuration and location information covered, he gets into the actual module building. He makes a simple "Hello World" module with a module.xml, event.xml and an Observer that handles sending the text back to the waiting application.

tagged: tutorial module magento2 module event observer

Link: http://www.eschrade.com/page/creating-a-module-in-magento-2/