views:

309

answers:

6

I want to know which php architecture strategies developers use in complex php applications . So far , i know the mvc structure which consists of models, views and controller (and controller plugins which handle with common tasks such as user access controller ). I know some good php frameworks which makes some common stuffs easier .But the problem starts when i thing about huge and complex php applications . because in these applications there are lots of stuff to do or lots of think to check, so i can not decide which code should be where .

Think about magento application , this is very huge application . when i review the source code of application , i can not understand the design strategy . i know there are some perfect design strategies which can handle very big php applications easily , because they can not build such a huge application with a very weak design strategy .the design strategy should support more than you want , so you can improve your code and application easily

To sum up , i want to how can i create bigger applications . Now the design strategies i use in my applications limits me , so i can not create more complex applications . i want to know which the design strategy can handle complex applications.

i know this is very abstract question , but this is because now my php background coming from amateur hobby not from academic . i want to do more , but i am in somewhere where i can not go one step more , because i can not find more complex info about coding . whatever ,to sum up , i want to know about design strategies for complex php applications such as magento .

Maybe the design strategies which i know (mvc , frameworks ci cake ...)can handle more complex applications than i think ..

if there are some mistakes in my questions please feel free to correct them , sorry for my inadequate english ..

A: 

It is indeed very abstract question and "very complex" is not very specific. When I hear people talking about "complex" applications I associate it with

a) Someone is using a complex architecture for a simple Problem. E.g. by using every design pattern and framework that sounded cool.

b) Someone tried to squish tons of entirely different usecase into a historically grown application, creating and using proprietary and undocumented interfaces and couple everything as tightly together as possible. Unfortunately CAN build huge applications with a bad design strategy and that is what makes them complex.

c) Legacy systems and Legacy System integration (ok see b)

Magento may be a big application, but the underlying Framework is still the Zend Framework, mainly its MVC part. So reading the Zend_Framework documentation will help you a lot to understand Magentos architecture as well (I won't recommend it the other way around by trying to dig into the Zend Framework through the Magento source). I would recommend to actually start building a bigger application with one of the MVC frameworks yourself, because that is the best way to learn the architecture and its benefits and where the limits are.

Daff
A: 

Which frameworks have you examined? Examine symfony, Zend Framework, and CakePHP if you haven't already. And by examine, I mean actually write medium-sized applications using these frameworks. Simply reading code is often not enough to get a grasp of how it works. You often have to actually use it and try to modify it.

You may also want to check out the book PHP 5 Objects Patterns and Practice for some ideas of design strategies that you may apply to your application. You may also learn quite a bit by studying frameworks written in other languages. The designers of many of the PHP frameworks were heavily inspired by Ruby on Rails, for example.

jkndrkn
+2  A: 

I believe that part of your problem may lie in the fact that creating enterprise applications is a problem in any language, and the design patterns that can implemented are actually language agnostic.

I would strongly recommend that you familiarize yourself with Patterns of Enterprise Application Architecture by Martin Fowler. This is the seminal work for any other books that you may later pick up that cover the same concepts in a language specific format, and if you want to truly understand what is required to create robust, scalable applications on the web then you'll need to familiarize yourself with this book.

A very common and popular design strategy with web applications right now is the Model-View-Controller paradigm. This has to do completely with separation of concerns in your application so that you aren't mingling database access code with html output.

For a pretty good treatment of the topic I would suggest that you look here (Zend Framework specific but it covers the general topic well) and here for a discussion about Models specifically. Or if you want to look at a more generalized PHP MVC tutorial, Rasmus Lerdorf has one.

In addition to this (and again you can learn this from PofEAA by Martin Fowler) you will need to learn about Object-Relational-Mapping what the strengths and weaknesses are of the various design patterns.

Unfortunately there are many good ways to do things depending on your needs, but for every good way there are about a zillion horribly wrong ways to them.

Noah Goodrich
Thank you for your reply . the link you gave is very useful for me . i just understood my weakest point , my problem is "fat controller = model + controller" problem .i think which limits my applications is that i do not have any 'useful' models, my models are just empty classes with framework's database adapter ,and i have huge controllers which have all logic in it . So i think i have to create real models
Oguz
.but i am not sure why do i need to create specific model action (for example user model's register action) even if i will use it in only 1 controller . one reason i can find is testing capabilities . if user model has a register method i can test it . if you have more information which can be useful for me , i want to learn. Thank you again
Oguz
@Oguz - Are you familiar at all with Don't Repeat Yourself, Single Responsibility Principle or encapsulation as they relate to Object-Oriented Programming?
Noah Goodrich
+1  A: 

If you haven't already, you should look into Object-Oriented Programming. There is a really great tutorial about that here. I think this is perhaps the most important thing that big web apps do that isn't necessarily intuitive to the amateur (myself included). The trick in MVC frameworks like Code Igniter is to build a series of classes (or objects) as either models or libraries.

Brandon Jackson
Would he mention design patterns if he didn't know OOP?
MiseryIndex
A: 

Well, even if your question just all about PHP... If you handle your static content like images with PHP it will result poor performance no matter using you MVC or not. You should use front end like nginx for such things.

look at http://highscalability.com/ real stories from real life!

Also note NoSQL.

Trickster