MH’s dev efforts

March 22, 2008

Scaffolding module v2

Filed under: Kohana, programming — Tags: , , , , , — mhordecki @ 9:40 pm

New version: http://mhordecki.wordpress.com/2008/06/29/scaffolding-maintenance-release/

Hello there. At the moment, as you can see, I’m ditching build.py case I’m a bit busy with other projects.

When writing my another PHP project (powered by Kohana, of course), named Milion Kostek (http://www.milion.rubiks-cube.c0.pl, non-English), I realized that, in fact, I’ve got nothing but one free hosting account shared with my friend shipped with one MySQL database to share between us. It’s unevitable that, when multiple systems use one database, each one must use table prefixes to avoid naming collisions.

Unfortunately, Kohana framework has got some flaws in field of table prefixes. Of course, such thing as $db->select(‘users.id’) works perfectly, but $db->groupby(‘users.id’) does not. What’s more, when I need to use sql functions, like $db->select(“concat(tableA.X,  ‘glue’, tableB.Y), I’m simply forced to write SQL query by hand. Even if I add table prefix manually, it will all fail cause query builder’s select method explodes it’s parameter by ‘,’ , so my concat call would be torn apart).

It’s easy to predict that I’ve ended up in writing my own query builder ;) . I almost complete, yet documentation is missing. As soon as I write it I will upload it here.

Nevertheless, using my Query library I could enchant my Scaffolding module. Here are the main changes:

  • Full support for table prefixes (;) )
  • Key fields can be now sql expressions (like my favourite concat)
  • Pagination in managementpage
  • Lots of minor bugfixes

Hope it will be useful for someone :)

Download link: http://rapidshare.com/files/101560292/scaffolding.zip.html.

How to install:

  1. Just drop it in modules/ folder in your Kohana app
  2. Enable it in $config['modules'] in your config.php (thanks nevez :) )
  3. Go to yoursite.com/scaffolding .

12 Comments »

  1. [...] Scaffolding module for Kohana PHP Filed under: Kohana, programming — Tags: Kohana, KohanaPHP, Module, PHP, Plugin, Scaffolding — mhordecki @ 9:48 am Edit: New version – check http://mhordecki.wordpress.com/2008/03/22/scaffolding-module-v2/ [...]

    Pingback by Scaffolding module for Kohana PHP « MH’s dev efforts — March 22, 2008 @ 10:12 pm

  2. install note to users: remember to enable the scaffolding module in application/config, otherwise kohana won’t find it

    Comment by nevez — March 23, 2008 @ 11:31 pm

  3. Just wanted to say a huge thanks for sharing your scaffolding module. I really love it. I’ve started tweaking the code and added Forge validation and used the inflector class to print ‘friendly’ form labels and table headers. With a bit more work (and a templating system) I think this would make a very robust admin interface. I can send you my version after I’ve had time to get a bit more done if you want.

    Comment by Stephen Beattie — April 16, 2008 @ 11:00 pm

  4. Hi, don’t you know, why this error happens?

    Fatal error: Class ‘Auth’ not found in D:\Html\test2\modules\scaffolding\controllers\mycontroller.php on line 16

    Even if I add the config to the scaffolding module with:
    $config['modules'] = array
    (
    MODPATH . ‘auth’, // Authentication
    );

    it’s not working :-/

    Thanks.

    Comment by Petr — May 8, 2008 @ 8:17 am

  5. I’m not sure of this, cause it’s strictly connected with your own Kohana copy. Scaffolding was tested with latest SVN trunk, but I doubt that would be a case. Check whether your auth module is sane. Have your modified any of Kohana/Scaffolding’s own files?

    @Stephen: It’s awesome that you’ve found my work useful:) I’d be glad to see your modded Scaffolding, is it accessible online somewhere?

    Comment by mhordecki — May 18, 2008 @ 7:19 pm

  6. I’m working on my CMS and scaffolding feature was planned for the frontend(s)… to insert (easy and fast) some test data. At this time I have no online test version ;-)

    I use latest svn version of Kohana, but my CMS is quite complex, so that error will be my fault :-) I have to solve it myself :-) At this time I focus on backend, so this problem will have turn little bit latter. But I will solve it!! ..I hope :-)

    Thanks for your reply and for your library anyway ;-)

    Comment by Petr — May 20, 2008 @ 11:38 pm

  7. I had to add:

    $config['modules'] = array
    (
    MODPATH . ’scaffolding’,
    MODPATH . ‘auth’
    );

    to get it to work. hope that helps if anyone wonders.

    Comment by Volante — June 12, 2008 @ 3:02 am

  8. scratch that, you also need forge to generate forms. :p

    $config['modules'] = array
    (
    MODPATH . ’scaffolding’,
    MODPATH . ‘forge’,
    MODPATH . ‘auth’
    );

    Comment by Volante — June 12, 2008 @ 3:04 am

  9. You can drop auth dependency if you hack mycontroller.php a bit.

    Comment by mhordecki — June 14, 2008 @ 3:39 pm

  10. this is cool! thanks for sharing it. it does not work right out of the box on 2.1.2 however–you should probably note that somewhere maybe?

    Comment by bunnyhero — June 19, 2008 @ 2:00 am

  11. Could I create a project at github with your code? I have some implementations to do and I want to share with you.

    Cheers

    Comment by rafaelss — June 27, 2008 @ 2:26 pm

  12. You’re welcome!

    @bunnyhero: At the moment I’m preparing the little maintenance release, so stay tuned.

    Comment by mhordecki — June 29, 2008 @ 3:54 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.