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

Rob Allen:
Using ZendConfig with a Slim app
Apr 21, 2015 @ 14:11:31

Rob Allen has a quick post to his site continuing his theme of Slim framework-related posts with this new post showing how to use the ZendConfig module with a Slim application.

Sometimes you need more configuration flexibility for your application than a single array. In these situations, I use the ZendConfig component which I install via composer: composer require "zendframework/zend-config". This will install the ZendConfig component, along with its dependency ZendStdlib.

He shows how to use the glob function to have the component load a set of configuration files and the order they'd load in. He also points out that the ZendConfig component supports other formats including YAML and JSON data. He also includes a code example showing how you can load multiple formats at the same time (ex. some .php files and some .yml files with one call).

tagged: slim application zendframework2 config component zendconfig tutorial introduction

Link: http://akrabat.com/using-zendconfig-with-a-slim-application/

Gonzalo Ayuso:
Building a Pimple/Container from a YAML file
Sep 29, 2014 @ 15:54:10

In a recent post to his site Gonzalo Ayuso shows how to create a Pimple container (a dependency injection container) from a YAML configuration definition using a simple handler already included in Pimple.

[In a conversation with Máximo Cuadros about Dependency Injection Containers] I said that I prefer Symfony´s DIC instead of Pimple, mainly because its configuration with YAML (or even xml) files. But In fact we can customise Pimple/Containers with YAML files in a similar way than we do it with Symfony’s DIC. In this example we’re going to see one way to do it.

While Pimple does come with the "Container" functionality to make this happen, Gonzalo points out that using it this way violates several of the SOLID design principles. Instead, he offers an alternate solution - using the Config component from Symfony to handle the creation of the container using an already established YAML format. He includes an example YAML configuration structure, the matching Pimple code for it and a code sample showing how the YAML is parsed into the same result. You can find the code on his GitHub account if you're interested in the full structure.

tagged: pimple symfony container solid config yaml dependencyinjection

Link: http://gonzalo123.com/2014/09/29/building-a-pimplecontainer-from-a-yaml-file/

ServerGrove Blog:
Symfony2 components overview: Config
Feb 21, 2014 @ 18:13:57

The ServerGrove blog has a new post today in their Symfony2 component spotlight series, this time focusing on the Config component.

After a few weeks, we continue with the Symfony2 components series. This time we are going to be talking about the Config component, which helps you to load and validate configuration values, regardless of their source.

They show how it can be used to parse YAML files and give a basic overview of its architecture. Sample code is included for a "blog generator" example that parses the given YAML structure and a loader to pull in the file. The component also includes caching functionality for larger configurations and allows you to define multiple loaders for different sources.

tagged: symfony2 component overview config yaml tutorial

Link: http://blog.servergrove.com/2014/02/21/symfony2-components-overview-config

Evan Coury:
Environment-specific configuration in Zend Framework 2
Jul 19, 2012 @ 16:36:06

Evan Coury has a new post looking at setting up environment specific configurations in a Zend Framework 2 application letting you switch between configs based on an environment variable.

So you’re all excited to try out ZF2. You clone the skeleton, install some modules, maybe even follow Rob Allen’s excellent ZF2 tutorial, and finally, start building your application. Now, if you’re a former ZF1 user or refugee from another framework, you might be troubled at this point by the fact that, at first glance, ZF2 doesn’t appear to take into consideration environment-specific configuration values (e.g., development, testing, staging, production). Luckily, this is not the case!

He includes a bit of sample code showing how you can use a simple getenv call to pull in the value from an "APPLICATION_ENV" environment variable and put it into an autoload path.

tagged: zendframework2 environment config variable getenv

Link:

Richard Thomas' Blog:
Solar Framework Shorts - Controlling form layout
Aug 17, 2010 @ 19:57:00

Richard Thomas has a new "Solar Short" posted to his blog to make life easier using the Solar Framework. This quick spotlight is about controlling the layout of the standard form renderer.

Solar's form system is pretty powerful and you realize the full beauty when auto generating forms directly from models but by default it uses a DL/DD/DT list for formatting your labels/inputs. If your not a fan of that formatting you can do something about it.

You can define the decorator tags in your framework's installation to replace the tags used for the list, element, label and the value output of the form. One of the comments on the post also suggests using the "decorateAsDiv" method the Solar_Form object provides to force the output into a div.

tagged: solar framework control form output config

Link:

Ben Scholzen's Blog:
Writing powerful and easy config files with PHP-arrays
May 11, 2009 @ 17:05:45

Ben Scholzen has written up a post about how regular PHP arrays can be used as a native configuration option for your applications.

I was asked many times how I organize my config files, and my response was always the same, until some time ago when I switched began refactoring the codebase of my blog. [...] Looking at [the advantages of PHP config files], you may ask now why not everbody is using them. Well the problem mostly is that you cannot create extend-sections (when working with Zend_Config for example).

He compares an example of a method that, using a base config file with some "smarts", you can have it automatically pull in certain files and overwrite settings from the array inside. A sample "other config" file is also included, showing the definition of some PHP settings, resources and database information.

tagged: configuration file array zendframework zendconfig smart base config

Link:

Make Me Pulse:
Using the Zend Framework URL rewriting
Jan 15, 2009 @ 13:55:15

New from the Make Me Pulse blog is this quick tutorial about bending the URL rewriting that the Zend Framework does to match whatever your needs might be.

Today for a good website’s referencement in Google, it’s necessary to have an URL rewriting. [...] If your application is based on ZF, we have a htaccess base file which will redirect all php files to the boostrap (what is the bootstrap ?), and ZF classes will manage all redirection rules. How to implement the URL rewriting with ZF classes ?

He sets up a config file (an ini file) with the routing instructions the framework will need to adhere to and shows how to get the application to include it and match against it for routing rules. His example sets a default route and several regular expression-based routes to remap requests right where they need to go.

tagged: zendframework config file ini routing regex default route tutorial

Link:

Abhinav Singh's Blog:
PHP Extensions - How and Why?
Dec 12, 2008 @ 17:17:23

Abhinav Singh has posted a guide to PHP extensions - what they are and how to write a simple "hello world" one.

Assuming you have read the previous post, lets discuss on how to build our first PHP extension: every PHP extension is built out of minimum of 2 files, a configuration file (config.m4) which tells us what files to build and what external libraries are needed and source File(s) which will contain the actual functionality.

He builds up an example skeleton for an extension (the config.m4) and explains how the file will be phpized and configured. Next up is the php_sample.h header file where the needed modules are loaded and the sample.c file to define them. Last, but not least, comes the extension code itself that calls the printf function to output the "hello world" message.

tagged: extension tutorial header file config phpize helloworld

Link:

Developer Tutorials Blog:
Why you should be using YAML for config
Jan 25, 2008 @ 17:22:00

The Developer Tutorials blog has a new post mentioning the use of YAML structure for creating configuration files in your application.

YAML, or YAML Ain't Markup Language, is a "human friendly data serialization standard". It's essentially a very basic format for storing data, and uses far less syntax than standard PHP. [...] It's almost like English; it's as basic as you want. Of course, that's not to say it doesn’t support complex structures - this example demonstrates the power of the format.

He also points out the spyc extension that makes working with the files in PHP a breeze.

tagged: yaml config markup language configuration file spyc

Link:

International PHP Magazine:
Three Releases - Graphing, Blitz and Plugins
Jul 04, 2007 @ 14:47:00

The International PHP Magazine has links to announcements of three new releases of PHP-related applications - the PHP Advanced Graph and Chart Collection, Blitz Templates and the Generic PHP Plugins & Config System:

  • PHP Advanced Graph and Chart Collection 5.1 provides a very easy way to embed dynamically-generated graphs and charts into PHP applications and HTML Web pages
  • Blitz templates 0.4.19 Blitz templates is a fast template engine written in C and compiled as a PHP module. It started as a php_templates replacement, but developed into much more.
  • Generic PHP plugins and config system 0.75 Plugin meta descriptions can reside as human-friendly comment blocks in .php scripts. Generic PHP Config reads them and facilitates plugin and configuration setting management.
tagged: application version release graph template plugin config application version release graph template plugin config

Link:


Trending Topics: