News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Kristopher Wilson:
Decoupling the Framework
December 02, 2013 @ 12:19:36

Kristopher Wilson has a new post to his site talking about something that could be very difficult with an existing application (and a good starting place for a new one) - decoupling from the framework. He advocates that your application shouldn't be an extension of the framework, more so a user of it to make it potentially easy to replace.

We spend a lot of time discussing and analyzing the features and merits of several frameworks, trying very hard to make sure we find the perfect one to use for our project. Rightfully so: picking the wrong framework can lead to a slew of issues down the road in terms of maintenance and scalability. [...] We also spent a considerable amount of effort making sure that there is minimal amount of coupling within our code. Strong coupling leads to problems testing, adapting, refactoring and reusing code. What if we applied that same principal to dealing with whatever framework we're using?

He goes on to look at the "framework is not your application" concept and fleshes it out with examples of it applied to a few different topics: Controllers, Models and ORMs. He also shows how, through the use of something like Doctrine's EntityManager, you can easily abstract things out so the internals of the application can easily split the application and framework.

0 comments voice your opinion now!
decouple framework controller model orm doctrine entity

Link: http://kristopherwilson.com/2013/11/27/decoupling-the-framework/

Benjamin Eberlei:
Decoupling from Symfony Security and FOSUserBundle
September 05, 2013 @ 10:37:43

Benjamin Eberlei has posted some of the results of his work at decoupling Symfony security from the FOSUserBundle, one of the "Friends of Symfony" packages that provides easy user management in your application.

In this blog post I will show how to decouple your core application from the Symfony Security component and User bundles such as the FOSUserBundle. [...] This blog post will add another perspective on how to achieve decoupling from Symfony user and security with a very simple approach. With this puzzle piece and others I wrote about before (Controllers as Service, Param Converters) and other pieces I still need to write about, I would classify Symfony2 as a good framework.

He talks about some of the dependencies this bundle introduces and one way to mitigate it by extending the User object with your own custom entities. His example is a "Customer" entity that only defines the "id" and "username" properties.

0 comments voice your opinion now!
symfony security fosuserbundle decouple example

Link: http://www.whitewashing.de/2013/09/04/decoupling_from_symfony_security_and_fosuserbundle.html

NetTuts.com:
How to Write Code That Embraces Change
February 04, 2013 @ 13:18:58

On NetTuts.com today there's a great new article about how to write code that embraces change and can be easily updated and reconfigured due to a decoupled nature and use of good OOP concepts.

Writing code, which is easy to change is the Holy Grail of programming. Welcome to programming nirvana! But things are much more difficult in reality: source code is difficult to understand, dependencies point in countless directions, coupling is annoying, and you soon feel the heat of programming hell. In this tutorial, we will discuss a few principles, techniques and ideas that will help you write code that is easy to change.

He covers some of the good OOP principles to think about when developing - like cohesion, orthogonality and coupling (via class methods, polymorphism, dependency injection or interfaces). He spends some time looking at the SOLID development principles and how you can implement each of them in some sample code. He also talks some about high level design and how the separation of concerns can help make your code easier to maintain and change.

0 comments voice your opinion now!
tutorial code change oop decouple dependency solid principles


PHPMaster.com:
Living Apart Together Decoupling Code and Framework
November 29, 2012 @ 09:32:21

On PHPMaster.com today there's a new post (by Remi Woler) that looks at abstraction and keeping functionality out of the framework and more decoupled in case the need for switching environments/frameworks comes up.

Of course you develop using the latest technologies and frameworks. You've written 2.5 frameworks yourself, your code is PSR-2 compliant, fully unit-tested, has an accompanying PHPMD and PHPCS config, and may even ship with proper documentation (really, that exists!). When a new version of your favorite framework is released, you've already used it in your own toy project and submitted a couple of bug reports, maybe even accompanied with a unit test to prove the bug and a patch that fixes it. If that describes you, or at least the developer you want to be: reconsider the relationship your code has with the framework.

He talks some about the dependencies most code written today has on the frameworks it lives in and how a good project design can make it easier to decouple this relationship. He suggests using things like wrapper classes (think "services") to abstract out the functionality to custom components. It's these components that handle the work, just reporting back the results to the controller/model that called them.

0 comments voice your opinion now!
decouple code framework tutorial module wrapper


Jani Hartikainen's Blog:
Decoupling models from the database Data Access Object pattern in PHP
January 05, 2009 @ 21:22:26

In this new post to his blog Jani Hartikainen looks at implementing the Data Access Object pattern in your PHP applications.

The advantage of this is that you can easily implement different methods to persist objects without having to rewrite parts of your code. I'm again going to use the programming language quiz game I wrote as an example. Since I initially wrote it to use Doctrine ORM directly, and both the old and new code are available, you can easily see how the code was improved.

He starts off with a look at the pattern itself (including a diagram of how an example would work with Doctrine) followed by the creation of the models for his Questions example. Add in the factory to create an instance and an exmaple of it in action and you're there.

0 comments voice your opinion now!
decouple model data access object designpattern tutorial doctrine


DevShed:
Decoupling the Validation of Data with Bridge Classes in PHP 5
January 10, 2007 @ 14:03:00

DevShed has posted part two of their look at working with bridge classes in PHP5, looking in detail at the decoupling of the data validation from an input form.

In the course of this second tutorial, I'm going to show you how to create a bridge class which will come in handy for decoupling the validation of user-supplied data. There will be a class that defines generically how certain data must be verified, while others will implement different validation methods.

They start with building a simple bridge class, a validator class that defines methods to check strings, numbers, alphabetic, and email values. For each of these types, they create the corresponding bridge class that validates the input. Finally, they tie it all together, validating an example of each, handled inside of try/catch blocks to watch for the errors that might be thrown.

0 comments voice your opinion now!
php5 bridge class decouple tutorial validation form php5 bridge class decouple tutorial validation form



Community Events











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


release hhvm framework facebook podcast series security unittest opinion composer package install component dependency symfony2 introduction language application code hack

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