Aspect-Oriented PHP
I am Bryan Saunders, and together with John Stamey and Matthew Cameron, we have developed an Extension to PHP to enable you to do Aspect-Oriented Programming with PHP. AOPHP 1.0 currently supports basic Before, After, and Around advice. Future versions will have more advanced support for these three types of advice. The Extension was developed using Java 1.5 and runs on Apache Web Servers. There are two parts to the implementation of AOPHP. The first involves using the Apache module ModRewrite, "the Swiss Army Knife of URL manipulation." The second is the aophpexec.aophp script which calls the AOPHP parser, written in Java 1.5. Aspects are written with a .aophp extension. These aspects are woven into incoming .php files by the Java AOPHP parser, contained in aophp.jar. For more information on AOPHP, visit http://www.aophp.net/ and For information on Aspect-Oriented Programming, visit http://www.aosd.net/ and http://www.aspectorientedprogramming.org/."
Can someone please try to explain to me what aspect oriented programming is all about?
I've consulted various websites, and I took classes about it, but I still don't get it.
I know it has something to do with modifying the behavior of code after that code has been written. However, all the terminology confuses me. What is it, exactly? What are all the buzzwords? What can and can't it accomplish?
Please correct me if I got my facts wrong.
Why put java into the mix? I can't think of any other reason than the authors realy, realy don't want this to be used anywhere. The compiler seems so trivial that it should be no problem coding it in php.
Honest question. Does anyone in the PHP care about this? Last I knew, they were just getting into objects with a halfway decent (though a little kooky) system. Isn't the PHP community mostly just people who want to bash out webpages, with the rest made up of people who think it's a good platform for large-scale frameworks?
I'm not trying to dis the community, those are valid concerns and there should be a tool for those people. But ISTM that AOP is much more likely to succeed in Java than PHP; one might as well try to introduce AOP to Visual Basic users. Hmmm... heh.
I think in Python so the whole idea of calling it a "paradigm" is a bit foreign to me anyhow; I was using it, as relevant, before it had a name, and I know LISPers were, too. A "technique", yes, a valuable one, but I'm not sure it is worth loading it down with the baggage of being a "paradigm" so much as a "good OO technique that is easier with language support but still possible without".
Note: yes, I know there is possible prior art to AOP but that doesn't change the fact that the USPTO has issued a patent on it.
Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
and I'll say it again:
Witchcraft!
Brought to you by a fist shaking, angst ridden C coder.
====
Crudely Drawn Games
Redirect all my URLs to a PHP script which is going to call some Java parser which presumably then spits out PHP which is then interpreted?
Either I'm nuts or they are.
"Elmo knows where you live!" - The Simpsons
Don't get me wrong, I think Java is a good solution for a certain set of problems (I haven't found any that I can't solve with other existing solutions, but I'm not a techno-bandwagoner like some folks), but not the end-all, be-all that Sun and the other "faithful" (read fanatics) claim it is. From my experience, it pretty well is an underperformer with more hype than reality (qualification: I've worked with Java since before version 1.0 and I'm still waiting for something more than a kind of Visual Basic for the Internet).
The AOPHP project seems to simply add more overhead and requires more system resources, exactly the kind of thing I know that everyone wants (seriously, I always have my clients come to me and ask for software that requires more hardware and still offers lower performance all the time ---- NOT!!!!).
But perhaps I'm just feeling curmudgeonly this morning and your actual mileage may vary...
Why implement it in Java? Why not just create a Zend/PHP extension using C, interface with the Zend engine's byte code executor and intercept function / method calls and execute advise functions before and after?
Then all you'd need is a single function to call in PHP like this:
aop_register_advice('my_function', 'my_advice_function', BEFORE_CALL);
aop_register_advice(array($myobj, 'myMethod'), 'my_advice_function', AFTER_CALL);
Code already exists to perform this kind of interception in PHP debuggers / profilers like APD and Xdebug.
One great aspect of open source is that, frequently, the code you need will probably already have been written. (pun intended)
Gabriel Ricard
You're using a java-compiled tool to make php scripts more powerful?
OK, i've heard of PHP extensions.
"PHP + compiled Extension"
But now, you want us to do
"PHP + Extension + JVM" ???
I don't want to troll, but... doesn't that make PHP run slower? Of course, if anyone can correct me, please tell me where i'm wrong.
IANAAOP but I think I get it enough to explain.
The purpose of AOP is to reduce repetition. Rather than writing repetitious tasks (like eg: security permission checking) into each function over and over, you write it once and attach it to all affected functions.
Taking that example of security, you can do it in non-AOP by just inserting a checkSecurity() call in front of each function - but you might miss some out and it's hard to maintain all that scattered code.
So, the big difference in AOP that I've noticed is: you can define this sort of "cross cutting" task in one place - and "push" it onto all the relevant functions from that same one place, rather than "pulling" it from each function with a call. This is IIRC usually done with some sort of regex, so you can say "all functions called security_foo (for any foo) get permission checked. Then if you add the new security_wibble() function, it will get checked without need to add or maintain checking code. Similarly, pre-existing functions that match the regex will be drawn into the checking too - you don't need to hunt them all up and make alterations in each.
It is a very vague patent that covers an entire paradigm of programming, not a specific implementation of any sort. For example, if Microsoft were to create "AspectVB" they could patent AOP programming for Visual Basic since it is a fairly specific idea. AOP however is an abstract idea that cuts across dozens of legitimate implementations.
IANAL, but I just don't see how they could actually use this patent to trash a specific implementation. They haven't gone after AspectJ so this is probably just a defensive patent anyway to make it impossible for big corporations to patent AOP in general.
Click here or a puppy gets stomped!
This whole "aspect-oriented" thing doesnt do anything that wasnt done before. There are many OO patterns that do the same job and dont incur the overhead of having a Java (!) extension. MVC (Model-View-Controller, http://c2.com/cgi/wiki?ModelViewController) separates the controller (which handles which "GotoPage" method to use), the view which handles all the presentation, the templating, etc. and the model, that actually does the logic part. Couple that with the intercepting filter pattern (basically, a chain of responsibility), which has the controller and an authenticate filter, and one filter per aspect, and you have a well-designed, reusable OO solution to the aspect problem. Aspect-oriented is just another word for layering, and layering has been the choice for software architecture for a long time.