Kohana Golden Hair is fork of Kohana Framework, based on Kohana 3.3.5 Framework.
Kohana Golden Hair is using NAMESPACES and supporting latest PSR-4 standart
Updated to work with PHP 7.0.x version. PHP 5.4 - 7.0.x compatibility
Released under a BSD license, Kohana Golden Hair can be used legally for any open source, commercial, or personal project.
Pagination module also added.
The major changes:
$subdomain = NULL
, if you are extending the class and this function add it.All modules was reworked for maximal compatibility with old code but Some of them still need to be tested. For example
New autoloader rewritten to seek classes files by namespace.
Underscore in class name now allowed.
All classes that only extends different classes where removed.
For example, there's no more Kohana class that extends Kohana_Core class.
Instead of this need to declare
use Kohana\Core as Kohana;
in every file where this class is used, e.t.c.
As file_seek function was also rewritten, Controller,Module and Views folder names now up to user.
In applications classes - controllers names now should be placed in a Controller namespace that should be the same as Controller folder name
When creating Instances of Models and other classes need to provide full Classname with namespace.
Like: $CaptchaTools = Model::factory('Sanuich\Captcha\Model\tools');
where Sanuich is a vendor's name, Capthcha is a Application name, Model is a part of path where Model is file tools.php
Or $CaptchaTools = Model::factory('Model\tools');
if Model tools lying in appllication\classes\Models folder
So Twig sais:
The PHP language is verbose and becomes ridiculously verbose when it comes to output escaping
Twig has a very concise syntax, which make templates more readable
We decided to fill some emptiness with a few lines of code. So now you can use in a Views some filters
To use filters in a View, third unnecessary parameter was added to View::factory function
$html = View::factory('index',$data, true);
by default it has value - false. To enable filters in a view - set this parameter to any value that !=false. 1 or true. Or define constant
define('VIEWS_FILTERS',1);
in index file or bootstrap file to enable filters in all Views by default.
Here is example of use escape filter
<? $str|escape ?>
<?=htmlspecialchars($str, ENT_QUOTES, 'UTF-8');?>
escape filter may be applied to variable or string. Any filter itself also may be filtered inside a text. But only one.
<h1>Members</h1>
<ul>
{% for user in users %}
<li>{{ user.username }}</li>
{% endfor %}
</ul>
<h1>Members</h1>
<ul>
<? foreach($users as $user){?>
<li><?=$user['username']?></li>
<? }?>
</ul>
In notepad++ (and other editors) symbols { and } - hilighted. So working with PHP code this manner more comfortable
date filter applicable to values of DateTime instances.
datestr filter applicable to values in a string format, supported by the strtotime function.
Both date and datestr filters accept date format string as a parameter. But in case of empty brackets or without brackets Default DateTime format will be applied.
"2012-03-04 00:00:00"|datestr("Y/m/d")
<? /* will output this */?>
2012/03/04
"2012-03-04 00:00:00"|datestr()
<? /* will output this */?>
2012/03/04
"2012-03-04 00:00:00"|datestr
<? /* will output this */?>
2012/03/04
Bundles is a new module for this Framework that allows to create separated applications in a public folder.
It is similar to modules, almost like modules, just allows to create each bundle in a public\bundles\vendor\bundle_name folder
That's why actualy was necessary to rewrite autoloader to PSR-4 standart
Some bundles added to default project:
There's a leak of documentation but default application in a app\classes folder is not empty.
Some additional sugar: new bundle Sanuich\Database that contains module Database with many useful functions to work with database
$SanuichDB = Model::factory('Sanuich\Database\Model\DB');
dbrow($q);
select with query $q and return one first row of result or falsedbidselect($q);
select with query $q and return array associated with value of id columndbinsert_data($tbl, $data, $replace);
insert or replace $data array in a table $tbl. $replace (0,1)dbupdate_data($tbl, $data, $key);
update table $tbl with record array $data WHERE $key==$data[$key]There are some examples of using new features below
$CaptchaTools = Model::factory('Sanuich\Captcha\Model\tools');
$captcha = $CaptchaTools->generatePassword(6,6);
$code = $CaptchaTools->dsCrypt($captcha);
$captcha_html = View::factory('Sanuich/Captcha/Views/captcha', array('code'=>$code));
$result = "";
if(!empty($_POST['captcha']))
$result = ($_POST['captcha'] == $CaptchaTools->dsCrypt($_POST['code'],1))?'correct':'wrong';
<script src="/bundles/Sanuich/AjaxControls/asset/js/core.js"></script>
Bundles::set(array('vendor'=>'Sanuich','bundle'=>'AjaxControls'));
<div id="msg"></div>
<script>get_data('msg','bye','','msg');</script>
$input = View::factory('Sanuich/AjaxControls/views/combobox',
array('button_name'=>'add',
'option_name'=>'name',
'fill'=>'get_names',
'button_click'=>'send()',
'input_id'=>'name',
'limit'=>'3',
'class'=>'name_div',
'option_class'=>'list_el',
'placeholder'=>'Input something'));
<select id="opt"></select>
<script>filloptions('opt','get_names','','names','','','');</script>
<table class="table table-bordered" id="tab"></table>
<script>filltable('tab','get_names','','names',1,1,1,'');</script>