views:

316

answers:

9

While it is most typically touted as a fully-featured shopping cart system, Magento is an awesome framework to boot. Of particular awesomeness is the layout system. In essence a page is created from "Blocks" which all inherit from an abstract class which does not assume the use of template files. These blocks are assembled according to a layout which is the composition of a bunch of XML files being merged together to describe a hierarchical structure of blocks for each page (inheritance supported for DRY). I love this system but Magento is a very heavy framework.

Are there any other frameworks which use a similar system? I.e. layouts that are defined outside of the template files as described aboive. PHP 5.3 is preferable but would consider frameworks in other languages.

FYI, if there are none that are suitable I'll continue using Magento stripped down to a barebones framework as I have been .

+1  A: 

Look at Symfony 2.0, it still in beta. http://symfony-reloaded.org/

will.i.am
Symfony 2 appears to essentially be HMVC like Kohana 3, which is nice, but HMVC doesn't handle extensions and injections like Magento's block system. Also, Symfony's "->extend" methodology tightly couples a view to a layout which kinda defeats the purpose of HMVC...
ColinM
A: 

I would stick with magento if you already managed to get your head around it. Why waste time learning another system? If speed is the problem, spend some time on optimising magento (there is a whitepaper on the subject which is a good place to start) and look into installing apc. It gives my magento installations a hell of a boost.

silvo
I've done a lot of system optimization already, even using apc.stat = 0 in production but it is still pretty slow. Such is the price of a good framework I suppose. -Thanks!
ColinM
A: 

I am currently working on CakePhp. It uses layout system. Also there is elements that you can create blocks on layout. It may work for you. Also not so hard to learn.

Ahmet Kemal
They're called "Elements", but the idea is the same.
Kalium
CakePHP appears to be the same as the others.. a view class that is essentially a glorified "include"
ColinM
But unlike Magento, CakePHP will not be able to control the template files using the layout XML. Please correct me if I'm wrong.
Knowledge Craving
@Knowledge_Craving I don't know much about Magento. But Cake has not XML style layout. It uses ctp files for viewing. You may be right.
Ahmet Kemal
+1  A: 

The Zend Framework is one such framework, which has almost the same structure as Magento and uses the correct MVC architecture (as many other versions of MVC architectures exist, which are implemented in many available PHP frameworks).

However, the Magento framework has been greatly modified by Varien, to suit its requirements, thus providing support for controlling templates & modules using XML configuration files. Also I think that this is Magento framework's unique characteristic feature.

So, all in all, I think Magento (with its barebones) must be used as you already are using & so does "silvo".

Hope it helps.

Knowledge Craving
Standalone Zend definitely does not come close with respect to Magento's layouts and blocks system, but so far it looks like you are right, Magento must be unique in this way. However, I'll hold off on accepting an answer for a while longer in hopes that there are still some good suggestions.
ColinM
A: 

Magento is build on Zend Framework. So, you may use this framework. But these days, almost all php frameworks use layouting system.

You can also consider Yii Framework and Doo PHP

bhoo-day
The typical MVC framework layout system (including Zend, Yii and Doo) is not even close to Magento's layout system..
ColinM
A: 

have you ever tried Kohana

yasirmturk
Yes I've used Kohana 2.3 and 3.0 but Kohana definitely doesn't have this feature built in.
ColinM
A: 

Suggest you take a look at Agavi http://www.agavi.org as it sounds like it does what you want.

Treffynnon
Agavi's layers and layouts come close, but it appears they are pretty much static once defined. Also, it seems the nested views can only be "pulled in" rather than injected unless I missed something. Magento's layouts can be extended and modified on the fly and blocks such as a sidebar can easily be extended purely via the layout system.
ColinM
You can also define them at runtime. Layouts are merely a convenient way of pre-defining the most common use cases. It's perfectly normal for applications to define different slots in different views, especially on the innermost layer (typically named "content"); think dashboards with a bunch of widgets or something.That of course also means you can always pass instructions regarding what sub-slots to render to a slot that you execute.
dzuelke
+2  A: 

Take a look at Symfony Templating component. It is fast, lightweight and powerful.

If you don't like PHP code inside templates, try Twig.

Both libs are standalone, support template inheritance and are easily extensible.

Sergiy
Symfony Templating is very nice.. However, there seems to be no designated way to inject content into a slot from outside of the template files (e.g. add a block to a sidebar from a controller). Seems like $this->add('sidebar','more content here') would do the trick so that could probably be extended easily.
ColinM
You can embed slot content from anywhere: inside template $this->set('sidebar', 'sidebar content...'), and from controller $engine->set('sidebar', 'sidebar content...'). But if you want to APPEND content to a sidebar, just concatenate it, e.g.: $engine->set('sidebar', $engine->get('sidebar') . ' appended content');
Sergiy
A: 

Not strictly a framework, But Drupal pretends to be a web-application-framework. You can strip Drupal to its bare bones and develop your own modules on top of it. Using its blocks system and templating engine.

berkes