News Feed
Sections




News Archive
feed this:

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

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

Link: http://www.sitepoint.com/building-processing-forms-in-symfony-2

Gonzalo Ayuso:
Auto injecting dependencies in PHP objects
March 05, 2014 @ 09:19:38

In his latest post Gonzalo Ayuso shows how you can automatically inject dependencies into your PHP objects with the help of Pimple, a simple dependency injection container.

I must admit I don't really know what's the correct title for this post. Finally I use "Auto injecting dependencies in PHP objects". I know it isn't very descriptive. Let me explain it a little bit. This time I want to automate the Hollywood Principle ("Don't call us, we'll call you"). [...] We need to use Reflection to create our instance and to call our action. Sometimes I need to work with custom frameworks and legacy PHP applications. I've done it in a couple of projects, but now I want to create a library to automate this operation.

He includes a simple example of a "Controller" class that is injected with a "Request" via constructor injection. He refactors this to create the dependency injection container with a "Builder" class) and shows how to fetch the instance of the "Bar" class from it. It's this Builder class he shares on GitHub.

0 comments voice your opinion now!
dependency injection container pimple builder class tutorial

Link: http://gonzalo123.com/2014/03/03/auto-injecting-dependencies-in-php-objects/

MaltBlue.com:
Do We Use Magic Methods or Not?
December 13, 2013 @ 10:39:20

In the latest post to his MaltBlue.com site Matthew Setter takes a look at magic methods. He tries to answer a few basic questions about them - are they worth using and can you truly test effectively when they're in use.

As a freelance Zend Framework developer, I'm always looking to improve the quality of the applications I produce. So over the last 6 - 12 months, I've been learning as much as possible about testing. During this time, I've found the way I code's dramatically changing (and improving). [...] In a recent development session, I attempted to test some of my ZendDb based classes, specifically the code which used the magic methods for dynamically building where clauses. [...] I can't speak for what it's like using PHPUnit's mock objects, as I always use Mockery instead. But after attempting to do so in Mockery, I hit a stumbling block when trying to test the chained call.

His example is a call to "lessThanOrEqualTo" to create his where clause that makes use of the "__get" magic method to get and return "Where" object. After some research (and conversations on IRC) he started wondering if the magic methods were worth the trouble they may cause during testing. He references this post and lists several of the comments made about their use, most of them not in favor.

0 comments voice your opinion now!
magic method zendframework sql builder query unittest testing

Link: http://www.maltblue.com/php/php-magic-methods-or-not

Alex Bilbie:
Introducing MongoQB
November 16, 2012 @ 09:38:38

Alex Bilbie has passed along a link to a project he's been working on to try to simplify access to MongoDB databases from PHP - his MongoQB library:

A few years ago I released a MongoDB library for the CodeIgniter PHP framework which has become quite popular thanks to it's likeness to CodeIgniter's query builder library. I've just spent the last week travelling and to keep myself occupied I spent some time re-architecting the library's code; removing the framework dependancy, making it Composer friendly and adding a full suite of unit tests. Check out the code on Github - https://github.com/alexbilbie/MongoQB.

The library makes it simpler to do most of the usual CRUD (Create, Read, Update, Delete) operations with your Mongo data. Example code is included in the post. This is a nice lightweight alternative to things like the Doctrine query builder.

0 comments voice your opinion now!
mongoqb query builder database project


Giorgio Sironi's Blog:
Refactoring PHPUnit's getMock()
August 19, 2010 @ 10:49:16

Giorgio Sironi has a new post to his blog about a "refactoring" he's done of PHPUnit's mock objects to make their creation with getMock easier.

Not an actual refactoring, but at least the introduction of a layer of indirection, a Parameter object, called PHPUnit_Framework_MockSpecification. I have already written the patch in a branch of my github repository. They are actually two independent patches, since PHPUnit core and the mocking component are in two separate repositories.

If you create a basic object, the creation is simple, but when you start wanting to use one of the other optional parameters down the line, things can get messy. His solution adds methods like disableOriginalConstructor and disableAutoload to make this simpler. You can find the patches on his github account.

UPDATE: This feature has been included in the latest PHPUnit master branch.

0 comments voice your opinion now!
phpunit getmock patch builder designpattern


Giorgio Sironi's Blog:
Practical PHP Patterns
January 11, 2010 @ 11:11:48

Starting off a new series on his blog Giorgio Sironi has posted two new tutorials looking at PHP design patterns - specifically the Abstract Factory and Builder patterns.

[This series will] touch the majority of the known design patterns, with a special look at their application in a php context. A running code sample will be provided for each part of this series, along with the theory and the terminology of each pattern.

In the Abstract Factory (or just Factory) post he includes a diagram of the pattern's relationship with other "participants" and has a Zend Framework-based code sample to create a simple WidgetHelper. In the second article he looks at the Builder pattern and how it can make creating instances of complex objects a bit easier. As before a diagram and code are included.

You can keep up with the rest of the posts in the series as they're added by following along here.

0 comments voice your opinion now!
designpattern tutorial factory builder


PHPBuilder.com:
PHP and Adobe Air Building a Time-tracking and Billing Application - Part II
April 07, 2009 @ 07:54:44

PHPBuilder.com has posted the second part of their series on creating a sample application - a time tracking app - with PHP and Adobe Air.

Welcome back. In part 1 of this series, you created some PHP remote services and the Clocked! widget application. Part 2 covers PHP administration and completion of the timer widget.

They're developing a Flex-based application (rather than the HTML/Javascript combo that can also be used with Air) so they'll be doing their work in Flex Builder. They set up a few placeholder functions like getClients, getProjects and getProjectsResult as well as support for the ticket and timer objects. Add in a few interface items like dropdowns for client and project selection and a start/stop button and you have the basic app laid out. The PHP interface to all of this Flex code comes in the next article of the series.

0 comments voice your opinion now!
time track air adobe tutorial series billing application flex builder


Jani Hartikainen's Blog:
Using a builder to construct complex classes
April 02, 2009 @ 12:58:28

If your code is getting more and more complex all the time and you find yourself creating a similar group of objects over and over, you might check out Jani Hartikainen's latest advice and create a "builder" around them.

Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters. [...] Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters.

His example is a "message builder" wrapper that lets you specify the receiver, sender and message and inject them into a to() method call (with a fluent interface). He shows how to make sure that the object you need (the message object) is always complete.

0 comments voice your opinion now!
fluent interface builder class complex tutorial


PHP-GTK Community Site:
Three New Posts - Two on Software, One on Web Services
May 02, 2007 @ 07:39:00

The PHP-GTK Community website has three new posts today - two concerning pieces of PHP-GTK software and one with news about the new RPC services the website offers.

First off is a look at the emuControlCenter software (version 0.9), a rom-manager for console and computer games:

emuControlCenter (ecc) is a rom-manager for retro and new console/computer games. ecc is build for people who want's to play retro games quick 'n' easy, without searching to much, ECC supports images and previews them directy in the 'Resultview'. Also there is a 'ImageCenter' build-in for a fullsize preview!

Next up is the PHP_Gtk Builderthis site for more information.

Finally, there's some information posted about the new web service offered by the site:

Starting today, the community site exposes a new XML-RPC service offering access to its daily statistics, in addition to the existing geo_nick API.

They include the list of information pages on getting started and using the API (like the access_stats API and a tutorial on getting started with PHP-GTK and the geo_nick service).

0 comments voice your opinion now!
phpgtk webservice xmlrpc accessstats builder emucontrolcenter phpgtk webservice xmlrpc accessstats builder emucontrolcenter


Edin Kadribasic's Blog:
New Windows Snaps/Release Builder
March 20, 2007 @ 08:18:00

Edin Kadribasic shares some great news on his blog this morning those using the PHP Windows builds will be happy to hear.

During my time at Emini I was using an old beat up machine to build PHP snapshots for Windows. It was only a Pentium II 400MHz and compiling a PHP snapshot on that machine took more than an hour. After leaving Emini I needed to find a new box for compiling PHP snapshots and PECL extensions for the Windows platform.

The light at the end of the tunnel came when Wez Furlong reminded him about a box OmniTI had that could handle just that. Now, what used to take over an hour to run takes around six minutes (a full compile of the latest snapshot with all of the extensions, including checkout and upload of the Win32 snapshot).

0 comments voice your opinion now!
windows snaps builder machine omniti opteron minutes windows snaps builder machine omniti opteron minutes



Community Events





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


interview symfony conference series opinion language version release podcast list composer artisanfiles voicesoftheelephpant framework community security laravel tool library introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework