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

Ramon Kleiss:
Introduction to Aspect-Oriented Programming
Aug 07, 2014 @ 16:09:10

Ramon Kleiss has posted a tutorial to his site recently introducing you to the concept of AOP in PHP (Aspect Oriented Programming). In it he provides an overview of some of be basic AOP concepts and code examples showing them in action.

For my first blog post, I'm going to take you on a little trip into a really cool programming paradigm: aspect-oriented programming, which is a little known style of programming while it can come in really useful. It is common knowledge that in software development you should have a Separation of Concerns (the first letter in SOLID). Although it is accepted that the Single Responsibility Principle is hard to design, it is still valued as one of the top best practices one can use.

He starts with a base class (ArticleManager) and how it's easy for it to grow when more dependencies are needed. He then evolves this example to use a more AOP approach, resolving the scope creep in the main class using cross-cutting concerns, advice, pointcut and aspects. He moves away from his basic example and uses a Symfony-based example to show how to implement a LoggingPointcut, inject it into the class and set up an "intercept" method to handle the notification of which method was called.

You will have to be careful to remember that you are using AOP as the application development continues, since it is very easy to forget about if you're happily developing away. Just take this rule of thumb: does the class I'm modifying care about the extra functionality? If it doesn't see if you can use inheritance or see if you can use AOP.
tagged: aspect oriented programming aop introduction example

Link: http://ramonkleiss.nl/intro-to-aop/

Codeception.com:
Nothing is Untestable: AspectMock in Action
Aug 01, 2013 @ 16:26:12

On the Codeception site they've posted a guide to using the AspectMock feature of the testing tool to prove that "nothing is untestable."

We already announced AspectMock, the mocking framework that may dramatically change the way you do testing in PHP. In this video Jeffrey Way shows how AspectMock is different from others. In this post we will demonstrate its powers too, and we will try to break some stereotypes about PHP testing. To get the code tested, you should always keep in mind how you would write a test for it. We know unit testing requires some good practices to follow and bad practices to avoid.

Their first example involves testing singletons, notorious for being difficult to test because of their "global" state. He also gives a more practical example using a Yii2-based application and a login form. True to its name, the AspectMock uses Aspect Oriented Programming concepts to make the "magic" happen behind the scenes.

tagged: codeception aspect mock aspectoriented unittest singleton

Link: http://codeception.com/07-31-2013/nothing-is-untestable-aspect-mock.html

NetTuts.com:
Aspect-Oriented Programming in PHP with Go!
Apr 10, 2013 @ 15:56:41

In this new tutorial on NetTuts.com today they introduce you to aspect-oriented programming (AOP) in PHP through the use of the Go! PHP library.

The concept of Aspect-Oriented Programming (AOP) is fairly new to PHP. There's currently no official AOP support in PHP, but there are some extensions and libraries which implement this feature. In this lesson, we'll use the Go! PHP library to learn AOP in PHP, and review when it can be helpful.

They start with a brief history of AOP in general and a basic vocabulary of some of the common terms like "point-cut", "aspect" and "cross-concern." They briefly look at some of the other PHP tools for AOP, but then help you get Go! up and running. Sample code is included showing how to integrate it into your project and, more practically, create a logging system that can be used as an aspect.

tagged: aspect oriented programming tutorial go library introduction

Link: http://net.tutsplus.com/tutorials/php/aspect-oriented-programming-in-php-with-go

NetTuts.com:
Aspect-Oriented Programming in PHP
May 11, 2012 @ 14:34:18

On the NetTuts.com (Plus) site there's a new tutorial focusing on aspect-oriented programming in PHP, a shift from the usual methods of development with the goal of "crosscutting" your classes/objects by weaving in extra functionality. Their examples of this method use the FLOW3 framework.

All modern frameworks (including FLOW3) push a lot of patterns into the software stack that do a great job at separating the concerns of your business logic; among them the famous MVC that is separating your logic into different layers. However, an application is not only built on business logic alone. As it grows, you may want to implement additional services, features, plugins or plugins of plugins. You surely don’t want this stuff in your business logic! But what are your options?

For their example, they show how to implement a logger across your classes, taking it out of the actual code and implementing it in an aspect (at the "pointcut") by "weaving" it into a DocBlock comment with special annotations. They help you get the FLOW3 framework set up and show you how to "kickstart" a new project and work with its controllers and resources. They show you how to implement the Logging aspect and how to define it in your code (and where it caches the requests).

tagged: aspect oriented programming tutorial typo3 flow3

Link:

Matthew Weier O'Phinney's Blog:
Aspects, Filters, and Signals, Oh, My!
Jan 11, 2011 @ 16:24:08

Matthew Weier O'Phinney has a new in-depth post to his blog that looks at a few features of Aspect Oriented Programming and what technologies are out there that help support it right now. He mainly focuses on the features of the Lithium framework because of its filtering techniques.

Last month, during PHP Advent, gwoo wrote an interesting post on Aspect-Oriented Design, or Aspect Oriented Programming (AOP) as it is more commonly known. The article got me to thinking, and revisiting what I know about AOP, Intercepting Filters, and Signal Slots -- in particular, what use cases I see for them, what the state of current PHP offerings are, and where the future may lie.

He gives a base class to help make things a bit clearer for the rest of the post - a simple Foo instance that uses a Listener interface to "doSomething". Matthew also talks about intercepting filters (extracting things like logging/debugging out of the code and put on its own) and signal slots. For both, he gives examples of how Lithium handles them and some of his opinions on the methods. He points out a few concerns that he has for the current state of AOP in PHP (frameworks) and suggests that, if you haven't looked at these ideas, you do so sooner rather than later.

tagged: aspectoriented programming aop aspect filter lithium

Link:

phpAspect:
New release of APDT
May 25, 2009 @ 17:37:54

As mentioned in this new post to the phpAspect blog, there's a new version of the Aspect PHP Development Toolkit that's been released.

The Aspect PHP Development Tools (APDT) project provides Eclipse platform based tool support for AOSD with PHP. Our goal is to deliver a user experience that is consistent with the PHP Development Tools (PDT) when working with PHPAspect projects and resources. This plugin provides an integration layer between the PHPAspect weaver, runtime and Eclipse/PDT extension points.

The Google Code page for the project has links to more information on the project and, of course, links to the latest downloads.

tagged: release tool development aspect apdt

Link:

William Candillon's Blog:
The new release of phpAspect is coming soon
Dec 18, 2006 @ 13:23:40

On his blog, William Candillon mentions an upcoming release of his apsect-based framework for PHP - phpAspect.

I have two weeks of holidays very soon, there will be dedicated to the release of phpAspect. Basically, I need to clean up some piece of code and finish to write the documentation.

Keep an eye on the project's page (on the Google Code Hosting service) for the update.

tagged: phpaspect aspect oriented programming project release phpaspect aspect oriented programming project release

Link:

William Candillon's Blog:
The new release of phpAspect is coming soon
Dec 18, 2006 @ 13:23:40

On his blog, William Candillon mentions an upcoming release of his apsect-based framework for PHP - phpAspect.

I have two weeks of holidays very soon, there will be dedicated to the release of phpAspect. Basically, I need to clean up some piece of code and finish to write the documentation.

Keep an eye on the project's page (on the Google Code Hosting service) for the update.

tagged: phpaspect aspect oriented programming project release phpaspect aspect oriented programming project release

Link:

Guilherme Blanco's Blog:
Transparent PHP AOP
Aug 02, 2006 @ 11:27:49

Guilherme Blanco has submitted a note about a project he's been working on, especially pertinent due to some of the discussion flying around on the subject - his Transparent PHP AOP project.

My AOP package implements this magic with PHP code in a transparent way. This means that the original code does not need to be altered in a special way to add or remove the aspects. It is only necessary to add a comment line to define the location of the pointcuts.

This package is actually a smart caching compiler. It preprocesses the original code to locate the pointcuts. Then it generates a new version that may include the code that implements the aspects that I want to enable.

In his blog entry, there are links to the package downloads and the official manual to help get you started as well as more details on some of the functionality behind the magic.

tagged: transparent aspect oriented transparent aspect oriented

Link:

Guilherme Blanco's Blog:
Transparent PHP AOP
Aug 02, 2006 @ 11:27:49

Guilherme Blanco has submitted a note about a project he's been working on, especially pertinent due to some of the discussion flying around on the subject - his Transparent PHP AOP project.

My AOP package implements this magic with PHP code in a transparent way. This means that the original code does not need to be altered in a special way to add or remove the aspects. It is only necessary to add a comment line to define the location of the pointcuts.

This package is actually a smart caching compiler. It preprocesses the original code to locate the pointcuts. Then it generates a new version that may include the code that implements the aspects that I want to enable.

In his blog entry, there are links to the package downloads and the official manual to help get you started as well as more details on some of the functionality behind the magic.

tagged: transparent aspect oriented transparent aspect oriented

Link:


Trending Topics: