Adding a REPL to Kohana
Having a REPL is very handy for experiment during development, this is how I added a Boris
REPL to Kohana PHP Framework.
Requirements:
- Composer http://getcomposer.org
- Boris https://github.com/d11wtq/boris
composer.json
:
{
"config": {
"vendor-dir": "application/vendor"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"d11wtq/boris": "1.0.*"
}
}
Load Composer's autoloader in bootstrap.php
:
/**
* Composer
*/
require_once(Kohana::find_file('vendor', 'autoload'));
modules/repl/classes/Task/REPL.php
:
<?php defined('SYSPATH') or die('No direct access allowed.');
class Task_REPL extends Minion_Task {
protected function _execute(array $options) {
try {
$boris = new \Boris\Boris('Kohana> ');
$boris->start();
} catch (ErrorException $e) {
Minion_CLI::write($e->getMessage());
}
}
}
After enable the minion
and repl
module in your bootstrap.php
, start the REPL with
$ php index.php repl
Profit!
Written by Tung Dao
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#