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

PHPMaster.com:
Practical Aspects of the Adapter Pattern
March 14, 2013 @ 09:08:02

On PHPMaster.com today there's a new post about using a design pattern in your application, specifically the usefulness of the Adapter pattern. This pattern makes it simpler to work with existing tools by providing a layer that allows unified access to the libraries from one interface.

Software development is improved every day by new concepts, methodologies, and high quality libraries and frameworks. But even with all these improvements, we cannot prevent change in software development. You may think that your system is designed perfectly to cater to all of its requirements, but there will always be a change request that ruins your perfect design. We have to be prepared for all possible changes as developers. The Adapter pattern is a design pattern which is commonly used to manage changes in development. Throughout this article we'll be looking at the usage and benefits of the patterns using real world applications.

He uses an illustration of email access via a mobile device and using it as an "interface" (via a SMS message) to the web to send an email. He then looks at a more practical code-based example, a set of adapters that let you subscribe/unsubscribe from various email services. He shows a wrong way to implement it as well as a good way - using it to work with Twitter to send tweets via a similar interface.

0 comments voice your opinion now!
designpattern adapter tutorial introduction email


PHPMaster.com:
Logging with PSR-3 to Improve Reusability
February 07, 2013 @ 10:22:26

On PHPMaster.com Patrick Mulvey has written up a new tutorial looking at using the PSR-3 logging structure to make a basic logger for your application.

Logging is one of the most ubiquitous tasks encountered in PHP. We use logs to track error messages, record important events, and debug problems with our code. In any PHP project, the code is likely to be full of calls to a logging library which handles these actions for us. [...] To promote compatibility between logging libraries, the PHP-FIG group recently released PRS-3, a common interface for logger objects. In this article, I'll discuss how the logger interface defined by PSR-3 allows us to write reusable code that isn't dependent on any particular logging implementation.

He includes a quick introduction to the PSR-3 format, how to get the files you'll need to use it (via Composer). He includes some sample code showing how to make the basic email class with a logger injected for use. Since the Monolog logging project follows the PSR-3 format, it's an easy drop-in option. He also talks about using PSR-3 to avoid having logger dependencies with the "LoggerInterface". There's also a bit at the end of the tutorial showing you how to use the Adapter design pattern to "proxy" the logging calls to the class via a PSR-3 interface.

0 comments voice your opinion now!
psr3 logging reusability tutorial monolog dependency adapter designpattern


DevArticles.com:
Singletons in PHP
December 06, 2011 @ 10:17:33

On DevArticles.com today there's a new tutorial posted talking about one of the more popular design patterns, the Singleton, and how it can be implemented in PHP.

Though in the past they enjoyed both popularity and a certain amount of prestige, without a doubt Singletons have progressively become one of the most evil and despicable villains in object-oriented design. Singletons earned their bad reputation for a reason: bringing them to life requires the programmer to deal at least with a static method. This is simply an elegant masquerade for creating a global access point (which in most cases is mutable as well) throughout an entire application. And we all know that global, mutable access is unquestionably a bad thing that must be avoided at all costs.

In this first part (of two) of the series they introduce the Singleton pattern and show how, via an example of using a database adapter interface to work with a MySQL database, in a tightly coupled example. In the second part of the series, they'll show how to break these apart using dependency injection.

0 comments voice your opinion now!
singleton designpattern dependencyinjection di mysql database adapter interface


Alberto Viana's Blog:
Zend Framework and Oracle XMLType
September 21, 2011 @ 09:52:04

Alberto Viana has a new post to his blog about using Oracle ZML Types with a Zend Framework application. He created a custom adapter to create the type and handle the binding/execution on an new OCI8 connection.

So few days ago I needed to insert Oracle XMLtype with Zend Framework. I used oracle adapter to wrote it in Zend Framework. I was looking for and I found on Chris Jones Blog.

His table has a column defined as an XMLType, a special data type specifically for working with XML datasets directly in the database. His adapter includes a bit of sample XML and the code needed to bind the data as a CLOB and, using the writeTemporary function.

0 comments voice your opinion now!
zendframework oracle datatype xmltype adapter


Zend Developer Zone:
My Favorite Design Patterns
April 25, 2011 @ 10:38:13

On the Zend Developer Zone there's a new article from Keith Casey where he talks about some of his favorite design patterns he's come across in his time as a developer - adapter, facade and decorator.

Within the Design Patterns world, there are four main categories: Architectural, Structural, Creational, and Behavioral. Architectural patterns describe the system as a whole, Structural patterns describe the relationships between objects, Creational handle creating objects, and finally Behavioral describe the communication patterns between objects. Each of the categories is worth discussion on its own, but in this case we'll stick to the Structural patterns of Adapter, Facade, and Decorator.

He describes each of the patterns (no code in this one, just descriptions) and for each mentions some of the tools that the Zend Framework has to offer that match up. For example, the Adapter pattern is used in quite a few places in the framework including in the Zend_Db component for the connection types to different databases.

0 comments voice your opinion now!
designpattern zendframework adapter facade decorator


Daniel Cousineau's Blog:
Doctrine 1.2 MSSQL Alternative LIMIT/Paging
September 17, 2010 @ 11:34:03

Daniel Cousineau has a new post to his blog today looking at an alternative that can be used for pagination in your MSSQL queries than the trick with TOP and reversing the ORDER BY in Doctrine.

As ugly as this technique is, it works. The problem is it requires an extreme amount of intelligence or an extreme amount of simplicity in the query in order for an automated system like Doctrine to be usable. The biggest caveat with this technique is good goddamned luck paging your query if it doesn't have an ORDER BY. And sometimes queries that are complex enough break the modified Zend_Db code. There exists an easier MSSQL paging technique. Using features first available in SQL Server 2005, with only 1 subquery you can mimic MySQL's LIMIT clause with ease.

He includes the query that will make it happen (the SQL for it) and then the implementation as an adapter you can use to get it to cooperate in your Doctrine queries.

0 comments voice your opinion now!
mssql doctrine limit paging adapter


NETTUTS.com:
A Beginner's Guide to Design Patterns
July 08, 2010 @ 08:47:55

On NETTUTS.com today there's a new tutorial that introduces a bit more advanced concept in the development process - design patterns.

Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it's much more than that. It is a template that has to be implemented in the correct situation. It's not language-specific either. A good design pattern should be implementable in most - if not all - languages, depending on the capabilities of the language.

They introduce a few of the more widely used patterns including the strategy pattern, adapter pattern, factory methods, decorator and singleton patterns. Each comes with a bit of code showing how it would work and a "where would I use this?" section with a better example.

0 comments voice your opinion now!
designpattern beginner strategy factory singleton decorator adapter


Richard Thomas' Blog:
Solar Framework Shorts - Using Multiple auth adapters
April 07, 2010 @ 15:56:30

Richard Thomas has posted another "Solar Short" to his PHPJack blog today dealing with a method for using multiple authentication methods in a single Solar framework installation.

What if you want to use multiple methods? OpenID? Facebook Connect? Saml? or one of the other dozen+ solutions that you might use.. What to do? One thing to keep in mind, Auth happens really early in the bootstrapping process so things like SQL may not be available yet unless you specifically loaded it in the config.. Then you need to load the proper auth module and call it as needed..

He includes a code example of how it would work - extending the Solar_Auth_Adapter to create a single "multi-adapter" with a switch to evaluate and load/use the correct authentication method. It uses the Solar_Config object to set the Auth Adapter when it's loaded so you can even use multiples in the same page load if you need it.

1 comment voice your opinion now!
solar framework multiple authentication adapter tutorial


ZendCasts.com:
Writing a Zend_Auth_Adapter with Doctrine
January 25, 2010 @ 09:54:32

New from the ZendCasts.com site today there's this new screencast looking at the integration of the Zend_Auth_Adapter component of the Zend Framework and the Doctrine ORM library to split out the authentication from the persistence layer.

I've been using Doctrine a lot in my own work, and recently found myself itching to have tighter integration between Zend and Doctrine when it comes to user logins. Luckily, Zend provides a very simple interface with regards to Zend_Auth. This way, it's easy to decouple your persistence layer (in my case Doctrine) from the authentication layer.

He also recommends checking out Palo Verede's look at the same topic. You can watch the screencast here and grab the code for it here.

0 comments voice your opinion now!
zendauth adapter doctrine authentication


Richard Thomas' Blog:
Solar Framework Shorts - Creating your own OpenID Auth Adapter
December 21, 2009 @ 10:09:01

Richard Thomas has posted another Solar framework short today. This time it's about OpenID and how you cn easily create a custom adapter that integrates directly into the framework to support it.

Solar makes heavy use of Adapter based classes, Solar_Auth is one of these. This makes adding additional methods pretty easy and allows you to borrow from other Frameworks without having to Hack in a third party auth setup, You can use the basics provided by Solar.

He includes a code example showing how to extend the Solar_Auth_Adapter component to create an OpenID adapter you can use as a part of your authentication process. His Solar component encourages code reuse too by using the Zend Framework native OpenID implementation as its authetication functionality.

0 comments voice your opinion now!
solar framework openid authentication adapter



Community Events





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


laravel community language code release api list opinion introduction framework unittest series interview podcast refactor symfony2 testing install threedevsandamaybe developer

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