Yiim - Yes It Is! Minifed - Mini Framework

Hello guys.

Last night in about 22:00 (European time), I’ve wanted to write my own ORM with simple save and update functions and find by PK, Attributes, SQL and to have methods for more results, like in Yii: findAllBySql, findAllByAttributes, etc.

I wrote that thing in about 4 hours. Then I was messing around with .htaccess and rewriting URL’s, and I’ve created a small router with single-request-controller (i.e. /about, /index, /etc) with no sub-action/action support currently.

When I’ve done that, I’ve realized that I have Model-Controller system, then I’ve just created a Renderer class witch will do the basic rendering.

I’m posting this as an example of my code and work I’ve done in 9 hours straight! This code is available on GitHub:

(since this is my first post, the link will be posted in my next post in this topic!)

(don’t ask for the branch name - it was my first commit ever there!)

Also, I’ve created a test landing page to see some basic options here.

One thing, I haven’t done the model inheritance like in Yii; but I have done something quite similar, so you’ll create an instance of a model like this:

// new data

$model = new Table(‘users’);

// find data

$model = Table::model(‘users’)->findByPk(1);

And you’ll get your results and you can do updates or inserts with: update() or save() methods built-in into the Models.

Also, I’ve created two rendering methods: render($file, $extractionParams) & renderText($text, $params) - with basic templating functions in the second method.

You’re reviews are quite welcome on any matter of this project.

You will notice that code is quick written and I haven’t commented almost nothing there, and there might be quite much bugs as I was able to discover, so help in that direction might be also useful for me.

PS I used no code from Yii - but I’ve used it as a foundation and basic idea - regardings how models, controllers and views should interact with eachother - and just to say a notice that I use Yii very offten in my projects and it was a lifechanger to me.

Thank you all for your reviews :)

Here’s my github repo for this project:

//github.com/reziraj/Yiim---Yes-It-Is--Minified-

ONE MORE IMPORTANT NOTE ABOUT THIS TEST PROJECT

I developed it in a FQDN on my local machine witch I’ve setup in my hosts file (nevermind the OS), and in my VHost configuration of my locale Apache:

You can add a simple vhost like this:

  1. Open your hosts file in your OS (linux: /etc/hosts, windows: /WINDWOS-INSTALLATION/system32/drivers/etc/hosts)

  2. Open a file where your virtual hosts are defined (in xampp: /XAMPP-INSTALLATION/apache/conf/extra/httpd-vhosts.conf

  3. Add a new host like this for instance:


<VirtualHost *:80>

    ServerName yiim

    DocumentRoot "C:/xampp/htdocs/yiim"

</VirtualHost>

  1. (optional) If you run on this line in your vhosts conf file:

#NameVirtualHost *:80

remove the # sign on the start of that line/uncomment that statement, so it should be just like this:


NameVirtualHost *:80

  1. Restart apache

And run your Yiim in browser - in my case it is just: //yiim/ :)

Sorry for not mentioning this before :)

no reviews for two whole days? something ain’t right!

well, this is the subforum for sites based on Yii (using Yii framework, not forks), maybe your topic is in the wrong place.

NOTE: topic moved to proper section (MIscellaneous instead of Yii-powered Applications)

Thanks @yavork for noticing that this is not a Yii powered app.

I think writing such code it is interesting and a quite fun, but what is a real purpose of this project?

Is is educational or training exercise?

Or do you want to make it useful for real life projects?

There are several mini-frameworks, like http://fatfree.sourceforge.net/, which try to be as lightweight as possible, maybe you can get some ideas from there too.

As for your code - the main thing it does not use PDO and, as I understand you create SQL by replacing placeholders in the SQL code with parameters using string_replace. This is not safe because this way you have no protection from the SQL injections - in yii parameters are bind to SQL command and PDO checks whether parameters are safe.

Also it looks a bit strange that Model extends Database which extends Config and actually you have single object which handles configuration, db connection and sql execution.