Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 12:26 AM, Manuel Lemos mle...@acm.org wrote: Hello, on 12/30/2008 05:07 AM Nathan Nobbe said the following: How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Well, I use, way of Rasmus (I give that name) and please read this why http://talks.php.net/show/drupal08/0 After you watch that presentation, the conclusion that you reach is if you want to develop a site that only shows a page saying Hello world! you should not use an MVC framework because it adds to much performance overhead! ;-) it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. I am not sure if that conclusion is correct. Were the benchmarks done using a PHP cache extension? im not sure, maybe ill ask him though. If not, the results may just show that Cake includes more code probably because it is more mature than others that are younger. hmm, im not so sure about that. code igniter is specifically designed to be fast, and it clearly is. it would be interesting to see feature comparison charts but im sure both zend and ci stack up against cake in that regard. What happens is that PHP code is compiled in zend opcode before executing. The more code split in include files you load, more time it spends loading the code before executing. When you use a PHP cache extension, the compile phase is skipped and replaced by loading compiled PHP code from cache. So most of the time is taken actually by executing the code. Therefore using the PHP cache extension may give more useful results to compare framework execution overhead. well, heres a series of tests that compare the aforementioned frameworks in much the same manner, using different caching solutions, and you can see the differences are grossly exagerated when the opcode cache is running. cake w/ the opcode cache is appauling compared to ci, and zend is substantially faster both with and without the cache as well. http://www.avnetlabs.com/php/php-framework-comparison-benchmarks i also like how rasmus shows several advanced optimization techniques, via strace and gdb. ive not used the 'included' extension, ill probly check it out. you know some of us yougin's never really got too much pratical exposure to tools like that =/ im still ramping up on these low level utilities myself. Those may not be the best tools to tell you what PHP code is taking more time to execute, as they only show system calls. i dont recall calling them 'the best tools'. i said 'advanced optimization techniques', which they can clearly can be. There are PHP profiler extension that give you a better vision of the actual PHP code that may be slowing down things. i dont think ive ever seen a warning about the system timezone misusage on a kcachegrind graph :p strace is more useful for PHP core developers as it tells which system calls are more expensive and could be worth some optimization. in general sure; but i would also say theyre fair game for the advanced optimizer as well. plus did you see the part about 'cleaning up the include path'. moving to require at the outer layer and as far in as possible, basically. thats a really good idea, and it looks like this 'includes' extension is well suited for tweaking in that manner. i may end up adding it in the arsenal alongside xdebug+valgrind. -nathan
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 1:05 AM, Nathan Nobbe quickshif...@gmail.comwrote: plus did you see the part about 'cleaning up the include path'. moving to require at the outer layer and as far in as possible, basically. thats a really good idea, and it looks like this 'includes' extension lol, its 'inclued' dummy :P -other dude
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 2:07 AM, Nathan Nobbe quickshif...@gmail.com wrote: on 12/30/2008 01:13 AM Sancar Saran said the following: and please read this why http://talks.php.net/show/drupal08/0 it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. One thing I'd like to point out is that hello world might show the overhead of putting something to screen, it doesn't touch the database or any of the harder parts of a real app like sessions acls. Things quickly go downhill from there. I saw these slides and started comparing my custom developed framework vs most of the standard picks out there. At first I was really disappointed with myself after seeing my apache bench numbers suck. Turns out when you actually start building an app mine wasn't nearly as slow as I thought. But on a simple hello world it fared pretty pathetically because it ran a lot of other routines that I always use in real apps, but not in hello world. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 10:15 AM, Eric Butera eric.but...@gmail.com wrote: On Tue, Dec 30, 2008 at 2:07 AM, Nathan Nobbe quickshif...@gmail.com wrote: on 12/30/2008 01:13 AM Sancar Saran said the following: and please read this why http://talks.php.net/show/drupal08/0 it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. One thing I'd like to point out is that hello world might show the overhead of putting something to screen, it doesn't touch the database or any of the harder parts of a real app like sessions acls. Things quickly go downhill from there. yeah, i dont think ive ever seen a real world app (more specifically an app from one of the companies ive worked at) that didnt hit the database on even the most simple of pages. I saw these slides and started comparing my custom developed framework vs most of the standard picks out there. At first I was really disappointed with myself after seeing my apache bench numbers suck. Turns out when you actually start building an app mine wasn't nearly as slow as I thought. But on a simple hello world it fared pretty pathetically because it ran a lot of other routines that I always use in real apps, but not in hello world. clearly there are other facets to compare, like a database layer would be nice to compare. ci uses what they call active record, which basically means runtime introspection of the database. im not sure how it works in cake or zend, but i know symphony has an abstraction layer which theyve already mapped propel and doctrine to. lots of room for performance differences there no doubt. what i tend to think about when i see these numbers tho, is that if i were to ever build a company w/ a php app that was slated for growth, cake would be probly the last option on the list. the differences arent so bad when you have a tiny website, but we've got 2000 servers at photobucket for example. imagine how many servers you can save at that scale w/ a php framework that does its job and gets out of the way. i just happen to know another popular web company here in denver running on some hacked version of cake, and honestly, i feel sorry for them :D -nathan
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 12:42 PM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Dec 30, 2008 at 10:15 AM, Eric Butera eric.but...@gmail.com wrote: On Tue, Dec 30, 2008 at 2:07 AM, Nathan Nobbe quickshif...@gmail.com wrote: on 12/30/2008 01:13 AM Sancar Saran said the following: and please read this why http://talks.php.net/show/drupal08/0 it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. One thing I'd like to point out is that hello world might show the overhead of putting something to screen, it doesn't touch the database or any of the harder parts of a real app like sessions acls. Things quickly go downhill from there. yeah, i dont think ive ever seen a real world app (more specifically an app from one of the companies ive worked at) that didnt hit the database on even the most simple of pages. I saw these slides and started comparing my custom developed framework vs most of the standard picks out there. At first I was really disappointed with myself after seeing my apache bench numbers suck. Turns out when you actually start building an app mine wasn't nearly as slow as I thought. But on a simple hello world it fared pretty pathetically because it ran a lot of other routines that I always use in real apps, but not in hello world. clearly there are other facets to compare, like a database layer would be nice to compare. ci uses what they call active record, which basically means runtime introspection of the database. im not sure how it works in cake or zend, but i know symphony has an abstraction layer which theyve already mapped propel and doctrine to. lots of room for performance differences there no doubt. what i tend to think about when i see these numbers tho, is that if i were to ever build a company w/ a php app that was slated for growth, cake would be probly the last option on the list. the differences arent so bad when you have a tiny website, but we've got 2000 servers at photobucket for example. imagine how many servers you can save at that scale w/ a php framework that does its job and gets out of the way. i just happen to know another popular web company here in denver running on some hacked version of cake, and honestly, i feel sorry for them :D -nathan I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Tue, 2008-12-30 at 12:15 -0500, Eric Butera wrote: On Tue, Dec 30, 2008 at 2:07 AM, Nathan Nobbe quickshif...@gmail.com wrote: on 12/30/2008 01:13 AM Sancar Saran said the following: and please read this why http://talks.php.net/show/drupal08/0 it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. One thing I'd like to point out is that hello world might show the overhead of putting something to screen, it doesn't touch the database or any of the harder parts of a real app like sessions acls. Things quickly go downhill from there. I saw these slides and started comparing my custom developed framework vs most of the standard picks out there. At first I was really disappointed with myself after seeing my apache bench numbers suck. Turns out when you actually start building an app mine wasn't nearly as slow as I thought. But on a simple hello world it fared pretty pathetically because it ran a lot of other routines that I always use in real apps, but not in hello world. You have it exactly right. In a hello world situation where my framework is leveraged properly, it beats the pants off plain PHP... why? Because with my framework I generally compile to the actually requested page, and hello world would result in static HTML content only... of course, as you'll see in some of these benchmarks they would encase the hello world output in a component, or module, or view or what-have-ye which really makes the comparison a bit contrived. And as Eric says, once you start loading in the database and all those other libs you need anyways just to perform your business logic, you will quite likely find that the difference between no framework and a good framework are at best minimal for server performance, while the framework approach provides ample benefits to architecural clarity and modularity. Obviously though, some frameworks/environments are pigs at the best of times... I'm looking at you Joomla :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Tue, 2008-12-30 at 12:53 -0500, Eric Butera wrote: On Tue, Dec 30, 2008 at 12:42 PM, Nathan Nobbe I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit A good framework will allow you to replace the introspection step with a static definition of the database table, thus easily bypassing the extra queries. Although, I can't fathom why they've requested all the tables. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 11:07 AM, Robert Cummings rob...@interjinn.comwrote: On Tue, 2008-12-30 at 12:53 -0500, Eric Butera wrote: On Tue, Dec 30, 2008 at 12:42 PM, Nathan Nobbe I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit A good framework will allow you to replace the introspection step with a static definition of the database table, thus easily bypassing the extra queries. Although, I can't fathom why they've requested all the tables. i think even w/o the static definitions, any sane framework would cache the schema definition somewhere, at least temporarily to keep performance reasonable. im not sure if thats the case, in any of these however. -nathan
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 1:07 PM, Robert Cummings rob...@interjinn.com wrote: On Tue, 2008-12-30 at 12:53 -0500, Eric Butera wrote: On Tue, Dec 30, 2008 at 12:42 PM, Nathan Nobbe I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit A good framework will allow you to replace the introspection step with a static definition of the database table, thus easily bypassing the extra queries. Although, I can't fathom why they've requested all the tables. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP To be fair cake did cache the show tables/describe magically for a few seconds if I sat there refreshing the page. :) I always generate my Gateways VO's from table definitions hand-code any non-crud statements. I've never really dealt with this stuff before but it is a little disheartening. I would rather take the 5 minutes re-generating a few files for an updated table versus infinite amounts of computer power wasted trying to just make it work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Tue, Dec 30, 2008 at 11:24 AM, Eric Butera eric.but...@gmail.com wrote: On Tue, Dec 30, 2008 at 1:07 PM, Robert Cummings rob...@interjinn.com wrote: On Tue, 2008-12-30 at 12:53 -0500, Eric Butera wrote: On Tue, Dec 30, 2008 at 12:42 PM, Nathan Nobbe I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit A good framework will allow you to replace the introspection step with a static definition of the database table, thus easily bypassing the extra queries. Although, I can't fathom why they've requested all the tables. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP To be fair cake did cache the show tables/describe magically for a few seconds if I sat there refreshing the page. :) I always generate my Gateways VO's from table definitions hand-code any non-crud statements. I've never really dealt with this stuff before but it is a little disheartening. I would rather take the 5 minutes re-generating a few files for an updated table versus infinite amounts of computer power wasted trying to just make it work. which bodes really well for something like symphony, but im not sure how bulky the orm abstraction layer is. that could end up ruining it in the end.. -nathan
Re: [PHP] Architecture patterns in PHP
Hello, on 12/30/2008 04:27 PM Nathan Nobbe said the following: I was following the blog tutorial on cake and here's what I got from hitting the post/index page: 081230 12:51:55 316 Connect r...@localhost on 316 Init DB cake 316 Query SHOW TABLES FROM `cake` 316 Query DESCRIBE `posts` 316 Query SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified` FROM `posts` AS `Post` WHERE 1 = 1 316 Quit A good framework will allow you to replace the introspection step with a static definition of the database table, thus easily bypassing the extra queries. Although, I can't fathom why they've requested all the tables. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP To be fair cake did cache the show tables/describe magically for a few seconds if I sat there refreshing the page. :) I always generate my Gateways VO's from table definitions hand-code any non-crud statements. I've never really dealt with this stuff before but it is a little disheartening. I would rather take the 5 minutes re-generating a few files for an updated table versus infinite amounts of computer power wasted trying to just make it work. which bodes really well for something like symphony, but im not sure how bulky the orm abstraction layer is. that could end up ruining it in the end.. I think that part of the problem here is that those so called ORM solutions are in reality ROM because they depart from the relational data model to the object model. Since they do that dynamically, even when they cache the results of reverse engineer the object model from the database table structure, there is always some overhead reading class structures from cache and rebuilding objects. This article talks precisely about that problem. http://www.phpclasses.org/blog/post/82-PHP-ObjectRelational-Mapping-ORM-or-ROM.html Personally I use a code generation based solution named Metastorage. It lets me defined my object models statically and then it generates efficient code for the classes that store and retrieve the application data objects. http://www.metastorage.net/ This allows more flexibility and productivity than most ActiveRecord based approaches, as it supports complex object models with relationships, validation rules, etc.. Then Metastorage generates smart code that only does what you need. There are no fat base classes to extend, nor ORM runtime libraries to include. The generated code is self-contained, i.e. it does all that is necessary without runtime libraries to add overhead to the execution of the applications. In cases that it is not necessary to use persistent objects (because the objects are not going to be changed), like for instance listing data or sending newsletters, Metastorage provides the concept of report classes, i.e. classes that just retrieve data for read-only purposes. It is much more efficient than using whole persistent objects because it only retrieves the object variables that you need into arrays. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
Hello, on 12/27/2008 10:57 PM Murray said the following: I'm interested in this topic as well. I'm starting out on a reasonably large web application, and I'm wondering at the best approach in PHP, particularly since it's been some years since I worked with PHP on a daily basis (the last 5 years have been purely C#). There's some dev community bias against using frameworks, isn't there? On one hand I'd love to take an approach that would make my end goal easier (thanks for pointing out Code Igniter, I'll look into it further), but on the other hand I'd rather avoid choices that 'tainted' (perhaps not the right word, but the best I could think of) the overall acceptance of the application once it's ready for release. I would not say there is bias against frameworks, but rather that there is no consensual around a specific framework. Some people prefer one framework, other people prefer others. Some people prefer relying on code written by themselves, others prefer using ready to code provided by others. One thing is certain, if you adopt a framework, you need to invest time learning how to use it. Some frameworks are not easy to learn and you end up spending more time than you wanted. Here is a longer reflection about using frameworks in PHP: http://www.phpclasses.org/blog/post/52-Recommended-PHP-frameworks.html So, currently I'm wondering about things like, 'Do I make an app that is a distinct page-per-function, or do I make an app that uses a monolithic index.php (similar to Wordpress?) and dynamically presents *everything*based on querystring values.' Personally I prefer to separate in different pages. It helps making things more organized. To sort out things that are more organized, some people use frameworks to help parsing URL parameters and route requests to different application modules. If you separate things, you do not need to build or learn any framework to handle things separately. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Sunday 28 December 2008 01:40:01 Michael C. Yates wrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Thanks Micheal C. Yates Well, I use, way of Rasmus (I give that name) and please read this why http://talks.php.net/show/drupal08/0 regards Sancar
Re: [PHP] Architecture patterns in PHP
Hello, on 12/30/2008 01:13 AM Sancar Saran said the following: How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Well, I use, way of Rasmus (I give that name) and please read this why http://talks.php.net/show/drupal08/0 After you watch that presentation, the conclusion that you reach is if you want to develop a site that only shows a page saying Hello world! you should not use an MVC framework because it adds to much performance overhead! ;-) Seriously, real world projects are way much more complex than simple Hello world! pages. Personally I do no use MVC frameworks (nor I have developed one) because they just add unnecessary complexity. However, separating concerns (processing, presentation, model data storage, distributed services, etc...) is a good thing to help keeping the project organization (and your mental sanity) as you project grows. You can separate concerns without using MVC, especial front controllers that go through many hops to sort which code to execute. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
Michael C. Yates wrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Thanks Micheal C. Yates I am an amateur programmer, so take my comments with a grain of salt (i haven't done heavy traffic long term projects). Having read through this thread no one has of yet mentioned Smarty.net http://smarty.net/ . Smarty is a template engine. It allows presentation to be separated with logic. I like it cuz my site designes usually end up looking like a 3rd grader designed it and you need some sorta special glasses to protect your eyes. However, i can do some solid logic coding (query DBs and whatnot). So smarty has been highly prized by me in my projects. But that is all i am doing is 'projects', those that usually lost money. But this is not because of smarty. Without smarty i wouldn't have even been able to get going. Also, it cleans up the code if you stick to the division principles. my USD 0.02$ which is a lot less now than it used to be... :( dK
Re: [PHP] Architecture patterns in PHP
On Mon, Dec 29, 2008 at 9:05 PM, Manuel Lemos mle...@acm.org wrote: Hello, on 12/30/2008 01:13 AM Sancar Saran said the following: How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Well, I use, way of Rasmus (I give that name) and please read this why http://talks.php.net/show/drupal08/0 After you watch that presentation, the conclusion that you reach is if you want to develop a site that only shows a page saying Hello world! you should not use an MVC framework because it adds to much performance overhead! ;-) it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. i also like how rasmus shows several advanced optimization techniques, via strace and gdb. ive not used the 'included' extension, ill probly check it out. you know some of us yougin's never really got too much pratical exposure to tools like that =/ im still ramping up on these low level utilities myself. -nathan
Re: [PHP] Architecture patterns in PHP
Hello, on 12/30/2008 05:07 AM Nathan Nobbe said the following: How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Well, I use, way of Rasmus (I give that name) and please read this why http://talks.php.net/show/drupal08/0 After you watch that presentation, the conclusion that you reach is if you want to develop a site that only shows a page saying Hello world! you should not use an MVC framework because it adds to much performance overhead! ;-) it also acts as a nice control mechanism to compare so many frameworks, trivial php, and html. really nice to see the numbers like that; so cake is horrifically slow, solar zend are pretty fast and code igniter is like twice as fast as those. I am not sure if that conclusion is correct. Were the benchmarks done using a PHP cache extension? If not, the results may just show that Cake includes more code probably because it is more mature than others that are younger. What happens is that PHP code is compiled in zend opcode before executing. The more code split in include files you load, more time it spends loading the code before executing. When you use a PHP cache extension, the compile phase is skipped and replaced by loading compiled PHP code from cache. So most of the time is taken actually by executing the code. Therefore using the PHP cache extension may give more useful results to compare framework execution overhead. i also like how rasmus shows several advanced optimization techniques, via strace and gdb. ive not used the 'included' extension, ill probly check it out. you know some of us yougin's never really got too much pratical exposure to tools like that =/ im still ramping up on these low level utilities myself. Those may not be the best tools to tell you what PHP code is taking more time to execute, as they only show system calls. There are PHP profiler extension that give you a better vision of the actual PHP code that may be slowing down things. strace is more useful for PHP core developers as it tells which system calls are more expensive and could be worth some optimization. -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
Nathan Nobbe wrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. Thanks for the reply. Does anyone know of a good written guide about patterns like Front controller, Page Controller, MVC etc. and how they are implemented in PHP? I found something about these patterns in a guide on MSDN called Enterprise Solution Patterns Using Microsoft .NET (http://msdn.microsoft.com/library/ms998516(en-us).aspx). It describes MVC, Page Controller, Front Controller and a lot of other patterns for ASP.NET applications. Something like this for PHP would be cool. Thanks Michael C. Yates -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Sun, Dec 28, 2008 at 3:29 PM, Michael C. Yates quw...@gmail.com wrote: Nathan Nobbe wrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. Thanks for the reply. Does anyone know of a good written guide about patterns like Front controller, Page Controller, MVC etc. and how they are implemented in PHP? I found something about these patterns in a guide on MSDN called Enterprise Solution Patterns Using Microsoft .NET ( http://msdn.microsoft.com/library/ms998516(en-us).aspxhttp://msdn.microsoft.com/library/ms998516%28en-us%29.aspx ). It describes MVC, Page Controller, Front Controller and a lot of other patterns for ASP.NET applications. Something like this for PHP would be cool. i used to be a pretty big fan of http://www.phppatterns.com its a bit dusty (not updated in years) but a lot of the material is still relevant, its free, and imo a great starting point. also, google is your friend ;) -nathan
Re: [PHP] Architecture patterns in PHP
The pup architect framework Book on zend also has excellent detail on the mvc pattern Bastien Sent from my iPod On Dec 28, 2008, at 5:38 PM, Nathan Nobbe quickshif...@gmail.com wrote: On Sun, Dec 28, 2008 at 3:29 PM, Michael C. Yates quw...@gmail.com wrote: Nathan Nobbe wrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. Thanks for the reply. Does anyone know of a good written guide about patterns like Front controller, Page Controller, MVC etc. and how they are implemented in PHP? I found something about these patterns in a guide on MSDN called Enterprise Solution Patterns Using Microsoft .NET ( http://msdn.microsoft.com/library/ms998516(en-us).aspxhttp://msdn.microsoft.com/library/ms998516%28en-us%29.aspx ). It describes MVC, Page Controller, Front Controller and a lot of other patterns for ASP.NET applications. Something like this for PHP would be cool. i used to be a pretty big fan of http://www.phppatterns.com its a bit dusty (not updated in years) but a lot of the material is still relevant, its free, and imo a great starting point. also, google is your friend ;) -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Architecture patterns in PHP
Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? And how many architecture patterns are there? Thanks Micheal C. Yates -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote: [snip!] Micheal C. Yates You mis-spelled your name, Michael. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Sat, 2008-12-27 at 19:00 -0500, Daniel Brown wrote: On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote: [snip!] Micheal C. Yates You mis-spelled your name, Michael. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! Lol! Epic spelling fail? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
dude, whatever Daniel Brown wrote: On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote: [snip!] Micheal C. Yates You mis-spelled your name, Michael. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. And how many architecture patterns are there? please do try to avoid pandoras box on the list ;) It can result in 100+ post threads, heh. that being said patterns are pretty general things, that's why they're called patterns. most of the time various languages will result in slightly different concrete realizations of a pattern, but you'll find most of them rather simple to realize in php. One that really isn't well suited to phps build-up / tear-down paradigm is the state pattern. much easier in java or cpp, imo. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
I'm interested in this topic as well. I'm starting out on a reasonably large web application, and I'm wondering at the best approach in PHP, particularly since it's been some years since I worked with PHP on a daily basis (the last 5 years have been purely C#). There's some dev community bias against using frameworks, isn't there? On one hand I'd love to take an approach that would make my end goal easier (thanks for pointing out Code Igniter, I'll look into it further), but on the other hand I'd rather avoid choices that 'tainted' (perhaps not the right word, but the best I could think of) the overall acceptance of the application once it's ready for release. So, currently I'm wondering about things like, 'Do I make an app that is a distinct page-per-function, or do I make an app that uses a monolithic index.php (similar to Wordpress?) and dynamically presents *everything*based on querystring values.' M is for Murray On Sun, Dec 28, 2008 at 10:05 AM, Nathan Nobbe quickshif...@gmail.comwrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. And how many architecture patterns are there? please do try to avoid pandoras box on the list ;) It can result in 100+ post threads, heh. that being said patterns are pretty general things, that's why they're called patterns. most of the time various languages will result in slightly different concrete realizations of a pattern, but you'll find most of them rather simple to realize in php. One that really isn't well suited to phps build-up / tear-down paradigm is the state pattern. much easier in java or cpp, imo. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
On Saturday 27 December 2008 6:57:18 pm Murray wrote: I'm interested in this topic as well. I'm starting out on a reasonably large web application, and I'm wondering at the best approach in PHP, particularly since it's been some years since I worked with PHP on a daily basis (the last 5 years have been purely C#). There's some dev community bias against using frameworks, isn't there? On one hand I'd love to take an approach that would make my end goal easier (thanks for pointing out Code Igniter, I'll look into it further), but on the other hand I'd rather avoid choices that 'tainted' (perhaps not the right word, but the best I could think of) the overall acceptance of the application once it's ready for release. So, currently I'm wondering about things like, 'Do I make an app that is a distinct page-per-function, or do I make an app that uses a monolithic index.php (similar to Wordpress?) and dynamically presents *everything*based on querystring values.' M is for Murray There are exactly 47 architectural patterns, not a single more or less. And if you believe that, I have a bridge you may be interested in. :-) Seriously though, you'll probably find an existing implementation of any architectural pattern in PHP, including the ones that have absolutely no business being implemented in PHP. (I include MVC in that, actually[1].) If you really want to know about OO patterns, pick up the Gang-of-Four book[2] and spend some time wrapping your head around it. (Warning: It is written mostly for a C++ audience, but it's still understandable.) Then ignore those patterns that require more setup effort on each execution than they take to run, as those are ill-suited to PHP's shared-nothing architecture. An active Observer, for instance, really sucks in a web app but a passive observer can do great things. Then, get over your OO biases. :-) PHP can do functions just as well as OO, and because of the setup costs in proper OO doing things with functions can often be much faster and require less mental overhead than building out a full OO setup. There are plenty of major projects (PHP and otherwise) that use virtually no OO and still manage to kick ass. (Drupal comes to mind, and the Linux kernel itself is all C code, which doesn't have syntactic OO.) Don't assume that architecture just means OO. Page-per-action vs. a front controller (the index.php to rule them all, usually with mod_rewrite) depends on your app and how you want to extend it. I personally far prefer a front controller approach as it means I can abstract out the bootstrap code and not even have the include this at the top of every page stuff. It does mean you want mod_rewrite if your app is going to be at all bookmarkable or googleable (you may or may not want it to be), but that's not a huge requirement. Disclaimer: I was asking this same question about 3-4 years ago, and started looking for PHP systems to study to learn from. I found Drupal, started using it directly, and haven't left yet. :-) That's probably not a bad approach to take. Find an existing system that feels right to you and run with that. You'll almost certainly get a better system out of it than trying to write everything yourself. (I've done that before, too, and it was generally a disaster.) [1] http://www.garfieldtech.com/blog/mvc-vs-pac [2] http://en.wikipedia.org/wiki/Gang_of_Four_(software) -- Larry Garfield la...@garfieldtech.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Architecture patterns in PHP
I think there is a lot to be gained from using a framework. I have an extremely large web app in asp ( over 1500 pages ) and maintenance is a frigging nightmare as it's so imtertwined. Using the code ignitor framework reduces that dramatically and I now have 5 rules based classes that control the majority of the app with the rest of the code being mainly basic crud and validation. The code is much cleaner, way simpler to maintain and the mvc pattern makes changes and additions a breeze. Sorry for top posting, ipod seems to prefer that for it's mail setup My 2 cents, though it's worth looking at other frameworks like qcodo, cake, or send to pick the flavor that fits you best Bastien Sent from my iPod On Dec 27, 2008, at 7:57 PM, Murray planetthought...@gmail.com wrote: I'm interested in this topic as well. I'm starting out on a reasonably large web application, and I'm wondering at the best approach in PHP, particularly since it's been some years since I worked with PHP on a daily basis (the last 5 years have been purely C#). There's some dev community bias against using frameworks, isn't there? On one hand I'd love to take an approach that would make my end goal easier (thanks for pointing out Code Igniter, I'll look into it further), but on the other hand I'd rather avoid choices that 'tainted' (perhaps not the right word, but the best I could think of) the overall acceptance of the application once it's ready for release. So, currently I'm wondering about things like, 'Do I make an app that is a distinct page-per-function, or do I make an app that uses a monolithic index.php (similar to Wordpress?) and dynamically presents *everything*based on querystring values.' M is for Murray On Sun, Dec 28, 2008 at 10:05 AM, Nathan Nobbe quickshif...@gmail.comwrote: Hey, How do you structure your web applications? I am thinking in terms of separating presentation and logic. How is that done in PHP? mvc is pretty popular, but php is so flexible you often don't need it for smaller applications. For example, if you take a page-controller approach, a php app is dead simple. You have a seperate entery point for evrything; login.php, register.php, etc could be considered controllers, then all your common logic comes in via some includes, hopefully files outside the webroot. then you have some template directory w/ files that are a mixture of php and html(for example). your 'controller' files include the library code, hit the db (if necc.) and then stuff data into the templates for output. if you want to see an exmple if a more traditional mvc there are scads of open source frameworks out there which use a front controller approach. Code igniter is really straight forward, you can probly learn quickly from it. And how many architecture patterns are there? please do try to avoid pandoras box on the list ;) It can result in 100+ post threads, heh. that being said patterns are pretty general things, that's why they're called patterns. most of the time various languages will result in slightly different concrete realizations of a pattern, but you'll find most of them rather simple to realize in php. One that really isn't well suited to phps build-up / tear-down paradigm is the state pattern. much easier in java or cpp, imo. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php