Login   Register  
PHP Classes
elePHPant
Icontem

Class: Transparent PHP AOP

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Guilherme Blanco  >  Transparent PHP AOP  >  Download .tar.gz .zip  >  Support forum Support forum (2)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Transparent PHP AOP
Base name: aop
Description: PHP AOP implementation based on cache compilation
Related classes: , , , , , , ,
Version: -
PHP version: -
License: Free for non-commercial use
All time users: 1026 users
All time rank: 2929
Week users: 1 user
Week rank: 2503
Picture of Guilherme Blanco
Author: Guilherme Blanco is available for providing paid consulting. Contact Guilherme Blanco .
Packages: 5 Browse this author's classes Browse this author's classes
Country: Brazil Brazil - PHP jobs in Brazil
Age: 28
All time rank: 18112 in Brazil Brazil
Week rank: 1036 Down73 Down in Brazil Brazil
Innovation award
Innovation award
Nominee: 2x


  Detailed description  
This package can be used to implement Aspect Oriented Programming (AOP) in PHP in a transparent way. This means that you can add or remove aspects to a class without changing its code.

The class provides an alternative for the PHP require() function that includes a PHP class and transparently modifies it to insert aspect advice code in the pointcuts defined in the class code that is going to have new orthogonal aspects added.
Also, it can automatically include advice code in automatic pointcuts, like at the begin and end of each method.

The pointcuts are marked in the class modify as simple PHP comments, so the class behavior is not affect when AOP support is not being used.
The automatic pointcuts do not need to be marked. This approach follows exactly the AOP theory, without need to touch a single line of 3rd-party code, for example.

The class is compiled and a new class file is generated with the code of the new aspects. The compiled class version is cached to avoid the recompilation overhead next time the same class is include using the same aspects.
The technique checks for changes in one of each XML file, or in original class file or even if new XML files were added/removed.

The aspects are defined in a separate XML file that includes the definition of the PHP advice code and the pointcuts where the code should inserted.

Optionally, the advice code can be compacted into a single line before it is inserted in the pointcuts, so the original class line numbers are preserved.
Another interesting option is to define the compiled files directory.

This package requires PHP 4.3.0 as it uses the PHP tokenizer extension. It does not use any external PHP extension.

 

  Groups  
Group folder image Language Constructs to assist in the language control View top rated classes

  Screenshots Screenshots   Video Tutorials   Rate classes User ratings  
  Trackback   Applications   Related links   Files Files  
  Files folder image Screenshots  
Transparent AOP in action
File Role Description
Accessible without login Image file screen.jpg Screen Transparent AOP in action


  Tutorial videos and presentations  
PHP Conference 2006 - Transparent PHP AOP: Trabalhando com Aspec
Title Description Duration
Video PHP Conference 2006 - Transparent PHP AOP: Trabalhando com Aspec Palestra sobre "Transparent PHP AOP: Trabalhando com Aspectos no PHP" por Guilherme Blanco, reali... 00:00:00

  Innovation Award  
PHP Programming Innovation award nominee
June 2006
Number 3
Aspect Oriented Programming (AOP) is a recent topic with growing interest in the software development community.

It allows adding and removing aspects to the main code of an application without changing its core code, making possible to adapt applications to the needs of different environments with little or no maintenance effort.

This can be used for instance to add logging and debugging support to an application without changing the code to be debugged. The debugging aspect code is defined separately from the main code.

This way the same application code can be used with debugging enabled on development environment, and debugging disabled on the production environment so it can run at maximum speed and with less memory usage.

Currently, like most other popular language, PHP does not provide built-in AOP support. However, there have been several attempts to emulate AOP concepts in PHP.

This package provides solution that achieves a great level of transparency. It can add new aspects to a PHP class without changing the original class code.

This package uses a compilation approach that works by generating a new version of the class that gets the new aspects added. A smart caching technique is used to avoid recompilation overhead when the same class is used with the same aspects.

When it is necessary to use the class without any aspects, the original class is used without the presence of any advice or callback code in the pointcuts, to not slow down the original class.

Manuel Lemos

  User ratings  
Ratings
Utility
Consistency
Documentation
Examples
Tests
Videos
Overall
Rank
All time:
Good (81.2%)
Good (93.8%)
Sufficient (75.0%)
Not sure (56.2%)
-
Sufficient (66.7%)
Sufficient (69.8%)
196
Month:
Not yet rated by the users

  Trackback links  
Link Description
Transparent PHP AOP RC3 A new version of Transparent PHP AOP is available...
Transparent PHP AOP 1.0 RC 2 I’m proud to announce you the new version of Transparent PHP AOP...
Experts vs. Expat XML A month ago I released the Transparent PHP AOP version 1.0 RC1. Now, I’m preparing the RC2 with some improvements scheduled...
register_superglobal( name ); Some time ago I spoke with Derick Rethans about the possibility to create a function called “register_superglobal”...
Robust Persistence Layer During the past two months, I worked in my graduation conclusion work (still not released - this version is not mine!). While programming the website, I had to deal with some kind of Object-Relational Mapping...
Transparent PHP AOP Recently I have released a new version of my package Transparent PHP AOP. It adds Aspect Oriented Programming (AOP) support to PHP...
What Happened to Aspect-Oriented PHP? | Garrett Bluma It's not every day that you find a lost branch of a programming language...

  Applications that use this class  
No application links were specified for this class.
Add link image If you know an application of this package, send a message to the author to add a link here.

  Related links  
Link Description
Transparent PHP AOP Online Manual Manual of usage available for consulting
Presentation Video Video of Transparent PHP AOP seminar (Portuguese Brazilian) - December 1st, 2006
Presentation Slides Slides of Transparent PHP AOP seminar (Portuguese Brazilian) - December 1st, 2006
Aspect Oriented Programming Theory What is AOP?

  Files folder image Files  
File Role Description
Files folder imagetutorial (3 files)
Plain text file aop.dtd Data DTD for XAD (Xml Aspect Definitions)
Plain text file CHANGELOG.txt Doc. List of changes
Plain text file class.Advice.php Class Advice
Plain text file class.AOP.php Class Main class
Plain text file class.AOP_CodeCompiler.php Class Class to compile AOP code
Plain text file class.AOP_CodeCruncher.php Class Auxiliar class do crunch PHP code
Plain text file class.AOP_CodeParser.php Class Class to retrieve PHP code as tokens
Plain text file class.AOP_XMLElement.php Class XML Element for XML Parser class
Plain text file class.AOP_XMLReader.php Class XML Parser class
Plain text file class.Aspect.php Class Aspect loader
Plain text file class.AutoPointcut.php Class AutoPointcut Class
Plain text file class.CustomPointcut.php Class CustomPointcut Class
Plain text file class.Pointcut.php Class Pointcut holder
Plain text file class.Weave.php Class Weave
Plain text file func.require_aop.php Aux. Function require_aop
Accessible without login HTML file Manual.html Doc. Manual of usage
Accessible without login Plain text file TODO.txt Data TODO List

  Files  /  Files folder image tutorial  
File Role Description
  Plain text file class.Test.php Class Tutorial Test class
  Plain text file debugger.xml Data Tutorial XML file
  Plain text file index.php Example Tutorial main script

Download all files: aop.tar.gz aop.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.