kohana

How to implement SimpleTest in Kohana

你。 提交于 2019-12-03 16:12:41
My boss assigned me to learn how to use Kohana and implement simple test in that. We would like to use it as our framework for future projects. Being new to both KohanaPHP and SimpleTest , I can't figure out how to do even the simplest test of my helpers. I can't even find a single step-by-step tutorial on how to attach SimpleTest to Kohana. Anyone here have an idea? We've created a SimpleTest_controller in Kohana and it gets the test from a directory tests define ( 'SIMPLE_TEST', '../tools/simpletest/'); require_once(SIMPLE_TEST . 'unit_tester.php'); require_once(SIMPLE_TEST . 'reporter.php')

Kohana — Command Line

。_饼干妹妹 提交于 2019-12-03 11:30:59
I'm trying to "faux-fork" a process (an email being sent via SMTP) in my web application, and the application is built on Kohana. $command = 'test/email'; exec('php index.php '.$command.' > /dev/null/ &', $errors, $response); I'm getting an error -- Notice: Undefined index: SERVER_NAME When I look into Kohana's index.php file, I see that it is looking for a variable named SERVER_NAME, but I guess it is coming up NULL because Kohana couldn't detect this value and set it prior to run. Any ideas how to get Kohana to run via command line? As far as I know you can't run the kohana files directly in

Which is the best way to display 'flash messages' in kohana v3?

守給你的承諾、 提交于 2019-12-03 09:36:31
问题 I would like to know the best way to display flash messages in Kohana v3? Some tutorials or examples would be helpful. 回答1: Do you mean like Kohana 2.x's flash session variables? The latest Kohana supports get_once() which is pretty similar to the old flash session variables. $session = Session::instance(); $session->set('test', 'Hello, World!'); // The session variable is returned and removed. $test = $session->get_once('test'); 回答2: I think the get_once is a great function, but what if you

Kohana3: Different .htaccess rewritebase and kohana base_url for dev and production environment

て烟熏妆下的殇ゞ 提交于 2019-12-03 09:25:18
问题 In my bootstrap.php I have the following: if($_SERVER['SERVER_NAME'] == 'localhost') Kohana::$environment = 'development'; else Kohana::$environment = 'production'; ... switch(Kohana::$environment) { case 'development': $settings = array('base_url' => '/kohana/', 'index_file' => FALSE); break; default: $settings = array('base_url' => '/', 'index_file' => FALSE); break; } In .htaccess have this: # Installation directory RewriteBase /kohana/ This means that if I just upload my kohana

Custom Exception Handling in Kohana3

久未见 提交于 2019-12-03 08:27:27
I have a requirement to create custom exception for the exceptions generated by my app/module. I want to consolidate all the exception classes in one place and handle the exceptions in one place. I might have generic exceptions, like mentioned below, which I would like in one common place input invalid internal error (database errors, smtp errors, other failures) permission denied session error I might have specific exceptions, like mentioned below email not valid, etc. Specific exceptions might be a subclass of generic exceptions in cases, like "email not valid" could fall under "input

Kohana 3 pagination

℡╲_俬逩灬. 提交于 2019-12-03 07:50:08
I'm really lost on how pagination works in kohana 3. Is there a good example of pagination in Kohana 3 anywhere? // Get the total count of articles $count = $this ->_profil ->articles ->count_all(); // Create the pagination object $pagi = Pagination::factory(array( 'items_per_page' => 4, 'total_items' => $count, )); // Find actual articles $articles = $this->_profil ->articles ->join_categories() ->order_by('id','DESC') ->limit($pagi->items_per_page) ->offset($pagi->offset) ->find_all(); and then in the View, you just do echo $pagi; // ofc, after passing the Pagination object to view What

Independent getter/setter methods, or combined?

本小妞迷上赌 提交于 2019-12-03 05:00:26
While working on a project, I've been making some changes and browsing around existing framework API docs for insight. While perusing the Kohana docs, I noticed that the getters/setters of any given class are typically combined: public function someProperty($value = null){ if(is_null($value){ return $this->_someProperty; } $this->_someProperty = $value; return $this; } Rather than: public function setSomeProperty($value){ $this->_someProperty = $value; return $this; } public function getSomeProperty(){ return $this->_someProperty; } Is there any value in doing this ( the former ), beyond

i18n and Error messages in Kohana 3

◇◆丶佛笑我妖孽 提交于 2019-12-03 03:48:37
I am developping an administration application with Kohana 3 and I'm obviously working with a lot of forms. The application needs to be multilangual and I'm very confused about how to manage my messages files and especially how to access them. Does i18n support different folders and files inside the language folder? E.g: i18n en form fr form Or does it support arrays in the language file? i18n/fr.php <?php defined('SYSPATH') or die('No direct script access.'); return array ( 'common_form' => array( 'error_type' => 'Error message in French.', 'error_type_2' => 'Other error message.', ) ) And if

Using $this, self::, parent:: for code readability

五迷三道 提交于 2019-12-03 02:48:59
I would like to know if it is acceptable/preferred to use self::method() and parent::method() when working in php classes. You can use $this->method() but $this-> can also refer to a class variable, a parent class variable, or a method from the parent class. There is no ambiguity in self:: Is self:: depreciated and/or are there any caveats or cons to using this style? I understand that self:: and parent:: refer to a static instance of the class, but in kohana, unless you specifically define a method as static, there does not seem to be a difference. Thanks. Added an example: Assuming this

Kohana 3 get current controller/action/arguments

爱⌒轻易说出口 提交于 2019-12-02 20:37:22
In Kohana 2 you could easily get that information like this: echo router::$controller; echo router::$method; echo router::$arguments[0-x]; Any idea how that works in Kohana 3? Thanks in advance! From inside a controller: $this->request->controller $this->request->action $this->request->param('paramname') Unlike K2 arguments in K3 are accessed via kays which you define in your routes. Take for example this url: Route::set('default', '(<controller>(/<action>(/<id>)))') ->defaults(array('controller' => 'welcome', 'action' => 'index')); To access the "id" argument you'd call $this->request->param(