News Feed

News Archive
feed this:

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

Programming Are Hard:
Structuring my applications, Cont'd
March 09, 2015 @ 12:03:16

The Programming Are Hard site continues its look at structuring Symfony-based applications in part two (it's just two parts) building on the structure and foundation laid out in part one.

It really irks me when I see some design/architecture decisions other developers have made but there's no technical explanation. What packages did they use? What challenges did they face? What trade-offs were made? I'll go over some more specifics in this post.

He recaps some of the things covered in the previous post first, ensuring everyone is on the same page. He then gets into the concept of "bundles" and how they encapsulate functionality. From there he talks about commands, controllers, dependency injection and lots of other topics, each with their own summary and a bit of code where needed for clarification.

0 comments voice your opinion now!
structuring application symfony bundle command controller di form provider repository resource serialize


Mathias Verraes:
Form, Command, and Model Validation
February 17, 2015 @ 12:34:38

In his new post Mathias Verraes talks about the separation of concerns that, in his opinion, should exist between form, command and model and the validation of each.

Many of the frameworks I've worked with, promise to separate responsibilities with MVC. In practice, the end up coupling everything to everything. The forms are coupled to the models, and there's a grand unified validation layer. This may be convenient at first, but it breaks down for larger systems, and creates headaches when having to support multiple clients. My approach is to clearly separate the validation for the form itself, from the Command validation and the model validation.

He talks about each of the different types in turn, starting with Commands. He suggests that the validation should happen in Value Objects in the Commands, validation rules in Models and some client-side validation (backed up by backend checking, of course) via Javascript or HTML5 fields.

0 comments voice your opinion now!
form command model validation separation concerns valueobject

Programming With Yii2 Exploring MVC, Forms and Layouts
February 03, 2015 @ 11:10:38 has posted the latest part of their "Programming with Yii2" series today that dives deeper into the functionality of the framework and investigates the use of MVC forms and layouts.

In Programming with Yii2: Getting Started, we set up Yii2 locally, built a Hello World application, set up a remote server, and used Github to deploy our code. This tutorial will cover some of Yii's more basic concepts related to its implementation of the MVC framework: Models, Views and Controllers. We'll also explore layouts and customization of navigation menus and Bootstrap elements.

They start with a look at the model functionality Yii2 has to offer and creates a first simple model, the "Status" model, to evaluate permission status. Next up is a simple controller, one that handles incoming status requests and either creates the record or displays the information in the model. Next is the output part of the application with examples of view handling, forms and layouts.

0 comments voice your opinion now!
tutorial yii2 framework series part2 mvc form layout introduction


Hari KT:
Aura Input Form Inside Slim Framework
September 08, 2014 @ 10:55:13

Hari KT has a new post to his site today showing how you can integrate the Aura PHP components into a Slim framework application for input handling, like from a form. Aura PHP is a set of decoupled components for things like CLI handling, dependency injection and SQL requests (among others).

Rob Allen wrote about Integrating ZF2 forms into Slim. I did write how you can use Aura.Input and Aura.Html to create standalone form for PHP. This time I felt I should write about integrating aura input inside Slim.

He includes the Composer configuration to install the HTML and Input components as well as an up-to-date version of the Slim framework. Code showing how to create the form class (a "Contact form") is included, showing both the creation of the elements and the filtering/validation checks put on each. He shows how the Slim routes would handle the request as well as how the view processes the request and displays the form via a helper. You can get the full working code in this repository over on GitHub.

0 comments voice your opinion now!
auraphp framework slim form input html tutorial


Rob Allen:
Integrating ZF2 forms into Slim
August 26, 2014 @ 09:40:47

Rob Allen has a helpful post if you've ever wanted to take advantage of the simplicity of the Slim framework and the power of the Zend Framework 2 forms. In this latest post he walks you through the process of setting it all up and using the ZF2 elements outside of the main framework.

Let's say that you want to use Zend Framework 2′s Form component outside of ZF2 itself. In this case, a Slim application. It turns out that Composer makes this quite easy, though there's quite a lot of code involved, so this is a long article. Start with a really simple Slim Application...

His simple Slim application - just one route - handles both the GET and POST actions and uses several ZF2 components besides just the Form (dependencies mostly). He shows you the updates and additions you'll need to make to the service manager configuration and how to set up some custom validation and the form object in the controller. His example form only has two elements, an email field and a submit button and validation is done on the email address when it's submitted. Finally he includes the View object, extended from Slim's that combines some of the ZF2 and Slim handling to correctly render the form.

0 comments voice your opinion now!
form integration slim zendframework2 tutorial validation


Rob Allen:
Globally overriding validation messages for ZF2 forms
August 19, 2014 @ 10:46:27

Rob Allen has posted a quick hint about overriding validation messages in a Zend Framework v2 based application. This override is related to the output of a standard form and works globally instead of just on a single form.

One thing that I always do when creating a Zend Framework 2 form is override the validation messages for a number of validators - EmailAddress in particular. I recently decided that I should probably sort this one out once and be done with it. Turns out that it's quite easy assuming that you use the FormElementManger to instantiate your forms.

The post includes all the code you'll need to do the override: a custom validator example, the changes you'll need to make to the configuration and an example of a form that uses the custom handling. He explains each of the parts too, showing how they fit together in your module.

0 comments voice your opinion now!
zendframework2 override validation message form tutorial

Form Validation in Symfony 2
June 12, 2014 @ 10:15:29 has continued their screencast series introducing the Symfony 2 framework and some of the basic concepts around things like routing, templating and controllers. In this latest post they build on a previous post and show how to use the form validation already built into the framework in some custom forms.

Today we're going to continue where we left off last time, where we learned how to build reusable forms in Symfony 2. In this video, we'll learn how to validate the data that has been submitted to our form to ensure it is in the correct format, meets our data's requirements and then process the form submission accordingly. [Once finished we'll] now have a working form, which validates our data and displays the validation error messages back to the user.

The screencast (also viewable on YouTube) is only about ten minutes long and shows you how to validate a form with an email address and that the other field is "not blank". He does base it off of the form created in the previous tutorial so if you haven't done that one yet, it's better to start there and come back.

0 comments voice your opinion now!
form validation screencast symfony2 tutorial series


SitePoint PHP Blog:
Building and Processing Forms in Symfony 2
June 06, 2014 @ 13:45:07

The SitePoint PHP blog has a new tutorial posted from author Daniel Sipos about form handling in Symfony2. More specifically, about creating them and handling the results from their submission. This is an introduction to the topic and gets into two examples, one focusing on a view implementation and the other using the form builder.

In this tutorial we will look at two examples of using forms in Symfony 2. In the the first, we will place form elements straight in the View file and then handle the form processing manually in the controller. In the second, we'll use the Symfony form system to declare forms in an object oriented way and have Symfony process and persist the values. We will be working on a simple installation of the Symfony framework.As you may know, it comes with a default bundle called AcmeDemoBundle and we will use that to illustrate working with forms.

In the first example he looks at "non-entity forms" and shows how to create the form from normal HTML elements in the view. The form is just a simple input field and a submit button. He includes the code you'll need to process the form submission too. In the second example he includes an example of how to create the same setup but using the Form Builder instead. It's also links it to a data object, making it simpler to save the submission results.

0 comments voice your opinion now!
symfony2 form processing view builder entity manager tutorial


Master Zend Framework:
Create a Simple File Upload Form in Zend Framework 2
June 04, 2014 @ 11:51:06

On his "Master Zend Framework" site today Matthew Setter has a new tutorial showing you how to create a simple file upload through the forms handling in Zend Framework 2. The form will include three parts: an input filter, a form class and a controller action to request to show the resulting form.

Having trouble getting file uploads integrated into your forms in Zend Framework 2? Or are you just curious about how to do it, and you want a quick rundown? If either of these is you, come walk through today's post with me as I show you a simple example of how it's done - along with how to combine it with filters and validators. Before we get started, I could have composed the code in a much shorter form than have I've composed it. But my assumption is that you're likely using the full-stack framework.

He includes summaries describing each of the three parts of the setup and the code you'll need to create each. The validator checks for things like "too big", "too small" and the correct MIME type on the file given. The form itself only includes the file upload element with a description of "Attachment". The controller action creates the form instance and calls an "isValid" when the upload happens to execute the validation. He also throws in the view template to display the form itself.

0 comments voice your opinion now!
zendframework2 simple file upload tutorial form


Master Zend Framework:
Howto Handle External Form Element Dependencies with FormElementManager
April 22, 2014 @ 11:58:07

The Master Zend Framework site has posted a tutorial wanting to help you understand external form element dependencies with help from FormElementManager.

Zend Framework 2, like all great PHP frameworks, provides thorough infrastructure for creating forms in your application. Whether that's form objects, form elements, fieldsets, validation groups or that they interact with so many other components in the Zend Framework 2 default libraries. But how do you handle external dependencies? [...] So what if you need a custom form element in your application, one which will render a list of articles from a database table? [...] In today's post, we're going to look at how to create such a custom element, extending the existing select element.

He walks you through the steps you'll need to make the custom element and hook it into the FormElementManager for correct use:

  • Create a New Form Element
  • Implement the getFormElementConfig Method
  • Create a New Form Object
  • Instantiate the Form Via the FormElementManager

Code is included for each step of the way so you can ensure you end up with a working example.

0 comments voice your opinion now!
external form manager element dependencies external tutorial


Community Events

Don't see your event here?
Let us know!

interview language series security laravel opinion video community api release example php7 extension library version podcast framework introduction laravel5 voicesoftheelephpant

All content copyright, 2015 :: - Powered by the Solar PHP Framework