[TYPO3-dev] Dmitrys Simple MVC
Dmitry Dulepov
dmitry.dulepov at gmail.com
Fri Apr 26 11:36:57 CEST 2013
Hi!
Elmar Hinz wrote:
> since a few weeks you are publishing your framework SimpleMVC on github.
>
> https://github.com/dmitryd/typo3-simplemvc
>
> I have some hopes that this could become the missing link between
> tslib_pibase on the one end and extbase/fluid on the other. It is
> especially interesting that it comes with twig as a template engine.
>
> Would you share the your thoughts and experiences with us.
> What kind of projects did you use it for?
I had a high-load web site built on TYPO3. It handles several thousands
online users on a single server. The site includes highly customized
forums, mail, photo galleries, blogs for people, news, search (using Sphinx
engine), favorites, etc. In other words, it is an active community portal.
It is used in production every day for about 2.5 years now. In addition it
powers a site for the big ice show company in Russia (friends of mine) + a
couple of projects at my work because it would speed up the development by
about 30% and let me avoid repeating myself.
Simplemvc was created for several reasons:
- I needed a framework to develop rapidly. Simplemvc does most of routine
stuff for me (such as config loading, merging with flexforms, language
handling, header files inclusion with just TS, etc). With this framework I
created a whole new community sites with more than 10 extensions working
for 3 months only in the evenings (1-2h). I would not achieve such speed
with any other framework because all other frameworks require more effort
from the developer for such simple things as extracting a field from he model.
- I needed database models that I could create quickly without defining all
properties. In the simplest case I should be able to just define a new
class with a single attribute inside it (a table name) and use the class
for loading&storing data. I did not want to bother describing every
property. See below for an example.
- I needed ajax support because the site was heavily ajaxed. So there is an
ajax controller with language/configration/action support. Just like the
regular FE controler but very lightweight.
- Speed, speed, speed. Due to thousands of users, I needed a solution of
VERY high performance. So I tuned and optimized for a lot of time and the
result is very fast!
- The framework must be very easy to use
An example of a typical database model class would be:
class AlbumModel extends AbstractModel {
static protected $tableName = 'tx_myext_album';
static protected $className = __CLASS__;
}
Yes, this is the whole model with all fields. And later in the controller
you do:
$album = AlbumModel::getById($this->getPostParameter('album_id'));
$album->setFooBar($this->getPostParameter('foo_bar'));
$album->save();
setFooBar() call will set a field named foo_bar in the database. Magic! :)
There is no repository because I believe it is not needed. It would mean
coding an extra class and spending more time for the developer.
Regarding the missing link: this ext does not use PiBase/Extbase/FLUID and
it never will. It is a separate piece of code.
> How far is the 6.x branch?
It is being converted from 4.x plus I am adding Twig (Symphony's templating
engine) for easier templating. Most of the work is pure backporting. I
expect the branch will be ready soon for real use.
One thing, which is missing is a kickstarter. That would be the next step.
Currently I use the good old kickstarter to create tables and add classes
manually. There is very little overhead, so adding files manually is
automated with PhpStorm file templates.
> Is it possible to start with the stable 4.x branch and switch later?
Yes, it is mostly compatible. All methods are the same or very close. Class
names in 6.x branch use 6.x conventions, so small changes will be needed.
Also Twig will be the default templating engine, so you may want to adjust
templates. But you can still use 4.x methods :)
--
Dmitry Dulepov
TYPO3 CMS core & security teams member
More information about the TYPO3-dev
mailing list