News Feed

News Archive
feed this:

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
August 07, 2014 @ 11: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.
0 comments voice your opinion now!
aspect oriented programming aop introduction example

Nothing is Untestable AspectMock in Action
August 01, 2013 @ 11: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.

0 comments voice your opinion now!
codeception aspect mock aspectoriented unittest singleton

Aspect-Oriented Programming in PHP with Go!
April 10, 2013 @ 10:56:41

In this new tutorial on 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.

0 comments voice your opinion now!
aspect oriented programming tutorial go library introduction

Aspect-Oriented Programming in PHP
May 11, 2012 @ 09:34:18

On the (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).

0 comments voice your opinion now!
aspect oriented programming tutorial typo3 flow3

Matthew Weier O'Phinney's Blog:
Aspects, Filters, and Signals, Oh, My!
January 11, 2011 @ 10: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.

3 comments voice your opinion now!
aspectoriented programming aop aspect filter lithium

New release of APDT
May 25, 2009 @ 12: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.

0 comments voice your opinion now!
release tool development aspect apdt

William Candillon's Blog:
The new release of phpAspect is coming soon
December 18, 2006 @ 07: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.

1 comment voice your opinion now!
phpaspect aspect oriented programming project release phpaspect aspect oriented programming project release

Guilherme Blanco's Blog:
Transparent PHP AOP
August 02, 2006 @ 06: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.

0 comments voice your opinion now!
transparent aspect oriented transparent aspect oriented

William Candillon's Blog:
Using XML Representations of a PHP parse Tree
June 08, 2006 @ 05:54:50

In his new post on "Yet Another PHP Blog" (a blog documenting his participation in Google's Summer of Code), William Candillon talks about some issues he had when working on his aspect-oriented framework.

The original PHP compiler doesn't use AST representation of a source code so in the previous versions of phpAspect I had to fill the php grammar with my own AST constructions. It was a painful job and moreover I had to do it in each major version of PHP. For this new version, I'm using the yaxx project written by Dr. Yijun Yu. The yaxx tool is a yacc skeleton which build an xml ast representation of a source code according to his grammar.

He includes two images, one showing the simple class code and the other showing the tree that's obtained from the XML generated by the yaxx tool for that class structure.

0 comments voice your opinion now!
xml parse tree yaxx aspect oriented programming images xml parse tree yaxx aspect oriented programming images

Sebastian Bergmann's Blog:
March 20, 2006 @ 06:54:17

As was mentioned in one of his previous blog posts, Sebastian Bergmann has been working up his own PHP version of an aspect-oriented framework. According to this new post, he's already done some work on the project and has created a page with more information.

As I wrote earlier, I am not satisfied with the Current State of AOP for PHP and started to work on AspectPHP a while ago. Today I am going to share my ideas on the subject.

What sets AspectPHP apart from other implementations of Aspect-Oriented Programming is its simplicity: aspects are plain PHP classes that declare pointcuts using annotations.

He gives an example of this kind of functionality, including a bit of code to illustrate. The example logs all method calls and, in this case, simply outputs them to the browser.

Unfortunately, he also mentions that, at this time, he doesn't have any code for the framework that he can release, but you can check out the site he's created for more information.

0 comments voice your opinion now!
aspect oriented programming aspectphp framework logging example aspect oriented programming aspectphp framework logging example

Community Events

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

language configure library application framework laravel list interview install developer threedevsandamaybe podcast wordpress unittest series code community api introduction release

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