Bug Report #4207
Kohana should enforce environment usage
| Status: | Closed | Start date: | 08/16/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Core | |||
| Target version: | - | |||
| Resolution: | wontfix | Points: | 1 |
Description
There are quite a few framework settings which depend on environment, like the `Kohana::init()` parameters, Route / CFS caching, etc.
Frameworks' default is Kohana::DEVELOPMENT, ending up with most users not even using environment states.
1. default .htaccess should contain SetEnv KOHANA_ENV DEVELOPMENT
2. `Kohana::init()` call in bootstrap should contain some env-dependant definitions (maybe even all parameters in this array should be passed with default values instead of having the defaults defined inside of this method):
Kohana::init(array(
'base_url' => (Kohana::$environment == Kohana::PRODUCTION) ? '/' : '/kohana/',
'index_file' => (Kohana::$environment == Kohana::PRODUCTION) ? FALSE : 'index.php',
'caching' => Kohana::$environment < Kohana::DEVELOPMENT,
'errors' => Kohana::$environment > Kohana::PRODUCTION,
'profile' => Kohana::$environment > Kohana::PRODUCTION,
));
3. Most users don't even know that Routes can be cached, the default should be:
/**
* Load routes if they're not cached yet
*/
if ( ! Route::cache())
{
Route::set('default', '(<controller>(/<action>(/<id>)))(.<format>)', array('format' => 'html|json|xml'))
->defaults(array(
'controller' => 'index',
'action' => 'index',
));
// Cache all Routes if caching is enabled
Route::cache(Kohana::$caching);
}
I'm quite sure there are many other things this methodology can be applied to, as long as they're not the things which can produce unexpected behaviour (default configs like in #4203).
History
Updated by Jeremy Bush 9 months ago
I don't think this should be incorporated by default. All this can/should be/is in the docs. Caching on by default is especially bad.
Updated by Kemal Delalic 9 months ago
@zombor: caching in this case would be only enabled when it doesn't change any behaviour (production caching of cfs and routes should be enabled anyways).
Updated by k03 n00b 9 months ago
I thought that the new Kohana version has become slower, until I realized that routes hasn't been cached.
So I agree with Kemal Delalić.
Updated by Sam de Freyssinet 9 months ago
These suggestions, all good ideas, do not belong in the vanilla distribution of Kohana. As Jeremy said, they should/are/can be documented instead. One size does not fit all.
Updated by Jeremy Bush 5 months ago
- Target version changed from v3.3.0 to Unscheduled
Updated by Woody Gilk 4 months ago
- Status changed from New to Closed
- Assignee set to Woody Gilk
- Target version deleted (
Unscheduled) - Resolution set to wontfix