Re: [Fwd: Re: [PECL-DEV] want to discuss - mvc extension]

From: Date: Wed, 12 Aug 2009 04:40:44 +0000
Subject: Re: [Fwd: Re: [PECL-DEV] want to discuss - mvc extension]
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-6573@lists.php.net to get a copy of this message
On Tue, Aug 11, 2009 at 7:33 PM, Greg Beaver <greg@chiaraquartet.net> wrote: > > > Sounds great. But I really want to know what I can benefit from this > "pureMVC" extension compared to those frameworks that written in pure PHP, > like Symfony, CakePHP... For the performance consideration? and is that easy > to extend this framework? > > I think it would be much better if you can provide some code example in > real world. hi greg, well the primary difference in my mind is that PureMVC is not an app framework like symphony, cake, etc. all it is is a model view controller, and a few other 'pattern implementation' classes like observer (mentioned in my first mail) and thats it. folks who look at an app framework and come to PureMVC will not get what they expect if theyre looking for something similar w/ PureMVC, theyre in for disappointment. 'just an mvc' in my perspective essentially means a high degree of loose coupling which is achieved through observer pattern. essentially, if youre in a proxy class for example and you want to say something to a mediator, you send a message, and you can pass along data. any mediators that are listening will respond to the event and execute the corresponding code theyve defined to handle said event. what is the benefit? i think there are several, and i also think there are several various targets for the extension, such as acting as the core of an application framework, and also perhaps it would fare well on an embedded box, like one of these 500MHz linux boxes folks run for routers, with web based configuration software. another benefit is the fact that we already have a user-space implementation of PureMVC, which means any application framework that decides to embed PureMVC as the core, will be able to boast the ability to run on all servers, including shared hosting servers, and have the ability to receive a healthy speed increase, by simply dropping in the native core. no other system offers anything like this for a core component of an application framework. the php port of PureMVC ships, w/ a simple demo site, which lets you see several views of the page rendered w/ different style sheets. once id gotten the extension working (used loosely in spite of issues folks here have raised :)) i decided to do some benchmarking. i took the demo app and created a static page from the output as a base line. using ab2 i compared the performance of the static page, to the page loaded w/ the userspace php port of PureMVC, then again w/ apc enabled, then again using the native extension. the extension beat out php+apc by roughly 60%, here are the numbers from my test, which id consider preliminary; the measurement is requests per second, so higher is better: static html: 588.69 native extension: 404.67 php (opcode caching on): 248.15 php (no opcode cache): 122.61 i have written a trivial demo app, which illustrates a bare-minimum use of PureMVC that id think pretty much any php oo programmer could understand. its the beat machine project from the heads first design pattern book, done w/ PureMVC for php. here is the page (remember, its a completely trivial page :)) ive specifically made it simple so people can see the bare bare basics and then take off running w/ it. http://nathan.moxune.com/puremvc/beatMachine/ ive also uploaded this code to github http://github.com/quickshiftin/beat-machine-PureMVC-demo-app/tree/master as far as performance goes i see a diminishing return on running native code at this level in the midst of a php application consistent of hundreds of thousands or millions of lines of php. maybe youd see a difference, but i sort of doubt it. that said, this is the limit of performance, right here. i dont see how any userspace mvc could beat the performance of a framework w/ native components - unless it was done really, really poorly i suppose :D also, i doubt anyone will do it, but the possibility will appear for existing frameworks to leverage PureMVC internally for a performance gain. coming to extension, i would suppose the most direct and common way, is to extend the native classes themselves, which is straight-forward. there are also plenty of options for composition as well, w/ the macro commands, the command component i might add exposes a composite pattern (which ive not yet settled on what i think is the most effective use). im not sure how much folks would really care to change the internal behavior, but if they want, there are many functions that can be completely overridden. another feature i want to incorporate, which ive barely started on, is the 'multi-core' support. this would enable 'modules' or multiple sets of Model, View, and Controller classes to co-exist at once, and i think that would greatly add to the extensibility out of the box. getting to the application framework ive been alluding to.., yes i think any serious app framework should really have C-based components in the middle; thats just how i feel about it. i think this project is very similar to the kinds of classes we're seeing from spl. iterators, observer, data structures and the like; this is the kind of stuff id seen spewing out of sun when java was catching fire years back, and i really think in the php world, we all know that the compiled code is the way to make it fast.. all code is magically fast in java, but in php theres a healthy line between the speed of userspace code and extension code. ive started in on what i regard as a 'thin' application framework around PureMVC which has the following features, . userspace or native core . modular class loader - out of the box support for classes named With_Underscores_Like_This, and another paradigm designed for namespaces, which also works under 5.2 (tw/ a little extra typing to replace require() calls) . url to code mapping - eg http://mysite.com/SomeClass/SomeMethod/SomeVariable maps right into a command class this and a little more, which i feel would appeal to the mass public as it will offer many of the conventions that have come to be expected of a php mvc based application framework, yet have some things i see as advantages here and there. one major feature will be the ability to drop zend framework classes right into your project and use them, which is part of the point of zends modular approach. im just offering a fast core, and some other options that some folks may take are leave, which is the way it goes w/ app frameworks imo. down the road, who knows, maybe we could port more to C over time. think about how much code is sitting out there, that hasnt changed for a few years, because its sitting at the middle of a vetted framework. why not port it to C, especially if you can click back over to the php version you already have of it at any time. i am far from finished on the app framework, i got about a week to crank on it after getting laid off from my last job, so be warned this doesnt even do anything at all yet. i need at least another week to get it to a point where i would have people try to use it at all. however, theres next to nothing in the public space that shows use of the PureMVC code w/ the php port, so consider this an early debut or something.. http://github.com/quickshiftin/phaca.de/tree/master -nathan

« previous php.pecl.dev (#6573) next »