Hey, just to keep you updated - I've created a ready-to-go Kohana 3.2 CRUD using Formo. The only thing you have to do is set up your ORM models correctly and it's working out of the box :D
Feel free to fill any issues or send useful pull requests.
maslen on #kohana (freenode) asked about guide on preparing Kohana application to be deployed on production server. As there's no official guide, I've decided to write few pointers of my own.
Here's a list:
if (isset($_SERVER['KOHANA_ENV'])) { Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV'])); } else { Kohana::$environment = ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? Kohana::DEVELOPMENT : Kohana::PRODUCTION); }
Kohana::init(array( 'base_url' => '/', 'index_file' => '', 'profile' => (Kohana::$environment !== Kohana::PRODUCTION), 'caching' => (Kohana::$environment === Kohana::PRODUCTION) ));There's also a profiling switch in Database configuration, don't forget about it. It may be a good idea to turn on caching for database too, depending on the project you're working on.
Of course it's not everything you can do to prepare your application for deployment. Don't forget about caching, use Fragment where possible and most importantly - don't be a cheapskate and don't try saving money on half-assed server.
While working on another database-to-html project I realized that 99% of pagination I'm doing is the same fragment of code so I isolated it into a very simple helper:
<?php class Helper_Pagination { public $pagination, $collection; public static function factory($jelly, $limit = 10) { return new Helper_Pagination($jelly, $limit); } public function __construct($jelly, $limit = 10) { if(is_string($jelly)) { $jelly = Jelly::query($jelly); } $this->pagination = Pagination::factory(array( 'current_page' => array('source' => 'query_string', 'key' => 'page'), 'total_items' => $jelly->count(), 'items_per_page' => $limit, )); $this->collection = $jelly->offset($this->pagination->offset)->limit($limit)->select(); } }
Can be quickly converted into standard Kohana's ORM:
<?php class Helper_Pagination { public $pagination, $collection; public static function factory($orm, $limit = 10) { return new Helper_Pagination($orm, $limit); } public function __construct($orm, $limit = 10) { if(is_string($orm)) { $orm = ORM::Factory($orm); } $this->pagination = Pagination::factory(array( 'current_page' => array('source' => 'query_string', 'key' => 'page'), 'total_items' => $orm->reset(FALSE)->count_all(), 'items_per_page' => $limit, )); $this->collection = $orm->offset($this->pagination->offset)->limit($limit)->find_all(); } }
Well, apparently I'm addicted to this framework and can't find any better replacement. Looks like I'm staying.
However I still believe in what I've written in this entry. I'm simply going to stop whining and implement some of these things on my own. You can say I have already started.
This one is in English because I hope more people will read it and comment on it.
As some of you know, I was a big Kohana fan ever since 2.3 version. It was my first solid framework and I grew fond of it to the point I've started writing modules (I've taken care of fredwu's Haml module, have written my own based on HamlPHP rather than PHamlP, I was also working on Scaffolder for Ko3.x). But now I'm tired and even a little bit pissed off, so I've decided to seek for my new PHP Garden of Eden of frameworks. Why?
Podczas testowania jakiegoś projektu zapewne wielokrotnie zdarzało wam się wkurzać, że nie możecie szybko i sprawnie przetestować metod w projekcie. Jakaś nowa libka, algorytm i zaraz kombinowanie, wrzucanie do osobnego pliku lub pisanie testów tylko po to, żeby sprawdzić czy dobrze zrobiliśmy regexp.
A gdyby tak... mieć interfejs CLI do takich zabaw? Taki interaktywny? Hmm?