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

Stefano Alletti:
Symfony and Monolog, how use Processor in your project: a practical example
Mar 17, 2017 @ 17:23:44

Stefano Alletti has written up a post to his site showing how to combine Symfony and Monolog along with a custom "processor" to modify the message and content being logged.

We often have to use different micro-services who write in many log files. Use utilities like Kibana is a good thing, but in order to take full advantage of its features we have to try to standardize and normalize the logs.

The company where I work having introduced Kibana recently, he asked me to implement a proper strategy to log all the micro-services.

He starts by outlining the fields that are required to be in the log output (a great place to start) before moving into the code to implement the logging. He briefly talks about Monolog itself and how to implement it in a Symfony application. The remainder of the post includes the code to implement the logger and how to add the custom processor to modify the extra data being included in the logged data. He also goes a step further and creates a custom formatter to modify the output in the message for the customer ID and product line values.

tagged: tutorial symfony monolog processor formatter integration

Link: https://stefanoalletti.wordpress.com/2017/03/09/symfony-and-monolog-how-use-processor-in-your-project/

SitePoint PHP Blog:
Creating Custom Field Formatters in Drupal 8
Mar 12, 2015 @ 17:29:01

The SitePoint PHP blog has a new tutorial posted today showing how to create custom field formatters in a Drupal 8 application. Custom formatters allow you to enhance the current functionality of objects in the application and extend them with additional functionality.

With the introduction of annotated plugins, a lot has changed in Drupal 8. We have a more streamlined approach to describing and discovering pieces of functionality that extend the core. Along with many other components, the former Field API (part of the larger and consolidated Entity API) is now based on plugins. In this tutorial we will go through defining a custom field formatter for an existing field (image). What we want to achieve is to make it possible to display an image with a small caption below it. This caption will be the title value assigned to the image if one exists.

They start with a new custom module, starting with just the YAML configuration. Then they help you create the field formatter as a plugin in the "Plugin/Field/FieldFormatter" namespace (code included). They explain how this code works and show how to add it as a hook to make it available to the template layer. Finally they show it in use and how it places the title value into the image caption in the result.

tagged: drupal8 custom field formatter tutorial plugin image title

Link: Creating Custom Field Formatters in Drupal 8

Ibuildings techPortal:
Zend Studio formatted for Zend Framework and ATK
Mar 18, 2010 @ 17:49:49

On the Ibuildings techPortal site today Ivo Jansch takes a look at a type formatter they've created to work with Zend Studio to more correctly format your code as per the official coding standard for the Zend Framework.

One problem we have with the current versions of Zend Studio is that its default Zend Framework formatter is not consistent with the official Zend Framework coding standard. Luckily, that can be easily fixed. Sandy Pleyte, one of our developers, created a formatting file for Zend Studio that does adhere to the formal standard. There might be a few issues here and there but we’ve found it to work much better than the default one in Zend Studio.

If you're a Zend Studio user and want to get a little less frustrated at the formatting it uses for your applications, download the tool and follow the instructions in the post to get it working in your IDE.

tagged: zendframework zendstudio formatter download

Link:


Trending Topics: