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

SitePoint PHP Blog:
Transducers in PHP Made Easy
Apr 19, 2016 @ 16:16:25

On the SitePoint PHP blog they've posted a tutorial showing you how to work with transducers in PHP. Transducers are pieces of functionality that allow you to transform data in a reusable way.

Have you heard of functional programming, high order functions, etc. before? Probably, right? However, when you hear “transducers”, do you know what those are? [...] A reducing function is just the kind of function you’d pass to reduce – it takes a result so far and a new input and returns the next result-so-far. A transducer is a function that takes one reducing function and returns another.

Transducers were first introduced into Clojure by Rich Hickey, and ported to PHP by Michael Dowling. Transducers are a powerful way to build algorithmic transformations that you can reuse in many contexts. In this article, we’re going to take a look at how they could be useful through a set of practical examples.

They help you get the mtdowling/transducers library installed via Composer and include a simple example using a User instance and uppercasing the first letter of the user's name. Other examples of the transducer functionality are also included such as: converting values to strings, filtering and composing sets of multiple transformations. The tutorial also shows you how to extend the current functionality and create your own transducer class (their example drops null values).

tagged: transducer functional programming reusable tutorial transform

Link: http://www.sitepoint.com/transducers-in-php-explained-and-demonstrated/

NetTuts.com:
Creating Reusable Forms in Symfony 2
May 28, 2014 @ 17:53:55

NetTuts.com continues their series covering some of the basics of using the Symfony2 framework with this new screencast looking at creating reusable forms.

In this video, we'll build upon our existing knowledge of Symfony 2 to learn how to create reusable forms. We'll learn how to create a separate form class to house our form logic, build the form in a controller and then render it to the browser, from a template.

In the previous parts of the series they built up knowledge on the basics, routing, controllers and templates. In this screencast they use their DemoBundle to create the Person object, make a form populated with its data (name) and the Twig template to render the form.

tagged: symfony2 series tutorial screencast reusable forms

Link: http://code.tutsplus.com/tutorials/creating-reusable-forms-in-symfony-2--cms-21244

DZone.com:
The Wheel: Symfony Console
Mar 13, 2013 @ 16:22:31

In this new post to DZone.com, Giorgio Sironi kicks off a series that looks at reusable components in the PHP development world. In this first post of that series he looks at the Symfony console component .

Symfony is one of the most popular open source PHP frameworks on the market. The Symfony Components, however, are loosely coupled projects that can be reused as a library outside of an application based on Symfony. The component this article explores is Console (symfony/console on Packagist and GitHub), dedicated to quickly build console applications.

He goes on to talk about some of the "pros" of using the component (including built-in argument/input handing and multiple "commands") and some of the "cons" of is use (including its size and some of the built-in features you can't really work around).

tagged: symfony console reusable component pro con commandline

Link:

Chris Hartjes' Blog:
Creating Usable Forms With Zend Framework
Jan 28, 2010 @ 16:48:16

Chris Hartjes has a new post to his blog today looking at how to make forms in a Zend Framework application in a bit more reusable fashion.

After searching around online for some examples of building simple forms, I was dismayed to discover there were two different ways of building the form. I could (a) do it the long way and create specific instances of the form elements using Zend_Form_Element_X or (b) do it the short way and add them to the form by use of Zend_Form::addElement() and pass it the type of form element I want via an array. For reasons I cannot explain initially, I decided to do things the long way. Later on, I found out that doing it this way saved me from rewriting.

He includes the code for his sample form that lives in a file outside the controller so he could use it for both the "add" and "edit" actions. He shows how to plug that into the controllers, the views to show the end result and a few decorators to get rid of the default form formatting and customize it how he needed.

tagged: zendframework form zendform reusable tutorial

Link:

DevCentral Blog:
Why Is Reusable Code So Hard to Secure?
Jan 08, 2010 @ 16:28:42

In this recent post to the DevCentral blog (from f5.com) they ask why reusable code, one of the foundations of good development (especially in PHP) is so hard to secure.

Being an efficient developer often means abstracting functionality such that a single function can be applied to a variety of uses across an application. Even as this decreases risk of errors, time to develop, and the attack surface necessary to secure the application it also makes implementing security more difficult.

The article talks about a project the author was working on and how, when he came across a need for a component and found one that worked, they were surprised to see how difficult it would be to secure it without adding on extra code bloat. He describes some of the issue and talks about how the development of the component must not have included any thought into things like input validation or filtering. One suggestion is to employ a firewall to sit in front of the entire application and handle all of these things without changes to the code.

tagged: reusable code security filter firewall

Link:

Mike Willbanks' Blog:
E-Commerce Framework Part 2
Aug 03, 2007 @ 13:44:00

Following up from a previous entry, Mike Willbanks has posted some clarifications on points previously made and the highlights on what he thinks a good framework should entail.

I decided to clarify and also explain some of my thoughts and ideas that an e-commerce framework should hold. These thoughts and ideas may be a little rough around the edges but I wanted to give a definition to the meaning of what I feel a framework is in this case as well as items that would potentially be a part of this framework.

Some of his requirements are things like reusable design, useful/easy to use components, functionality for both payment processing and courier handling as well as a catalog system to help manage items.

tagged: ecommerce framework part2 reusable library payment courier ecommerce framework part2 reusable library payment courier

Link:

Mike Willbanks' Blog:
E-Commerce Framework Part 2
Aug 03, 2007 @ 13:44:00

Following up from a previous entry, Mike Willbanks has posted some clarifications on points previously made and the highlights on what he thinks a good framework should entail.

I decided to clarify and also explain some of my thoughts and ideas that an e-commerce framework should hold. These thoughts and ideas may be a little rough around the edges but I wanted to give a definition to the meaning of what I feel a framework is in this case as well as items that would potentially be a part of this framework.

Some of his requirements are things like reusable design, useful/easy to use components, functionality for both payment processing and courier handling as well as a catalog system to help manage items.

tagged: ecommerce framework part2 reusable library payment courier ecommerce framework part2 reusable library payment courier

Link:


Trending Topics: