kohana

Proper way to use a config file?

I just started using a PHP framework, Kohana (V2.3.4) and I am trying to set up a config file for each of my controllers. I never used a framework before, so obviously Kohana is new to me. I was wondering how I should set up my controllers to read my config file. For example, I have an article controller and a config file for that co...

Kohana input & validation libraries - overlap?

I'm familiarizing myself with Kohana. I've been reading up on the Input library, which automatically pre-filters GET and POST data for me, and the Validation libary, which helps with form filtering and validation. Should I use both together? The examples given in the Validation library documentation use the unfiltered $_POST array ins...

Should I refactor this code?

The code is for a view debate page. The code is supposed to determine whether or not to show an add reply form to the viewing user. If the user is logged in, and the user is not the creator of the debate, then check if the user already replied to the debate. If the user did not already reply to the debate then show the form... Otherw...

How to perform an external request in Kohana 3?

I've always used cURL for this sort of stuff, but this article got me thinking I could request another page easily using the Request object in Kohana 3. $url = 'http://www.example.com'; $update = Request::factory($url); $update->method = 'POST'; $update->post = array( 'key' => 'value' ); $update->ex...

How to structure a Kohana MVC application with dynamically added fields and provide validation and feedback

I've got a bit of a problem. I have a Kohana application that has dynamically added fields. The fields that are added are called DISA numbers. In the model I look these up and the result is returned as an array. I encode the array into a JSON string and use JQuery to populate them The View knows the length of the array and so creates ...

What sort of exceptions should I be throwing from inside Kohana 3?

I've seen the code examples on this article, but throwing Controller_Exception_404 produces an error. I've just been throwing plain exceptions. I remember in Kohana 2.3 there were different ones you could throw, depending on the situation. Does anyone have a list of what exceptions should be thrown when? ...

PHP core function printing debug statements

I'm integrating a framework (Kohana 2.3.4), into a web-app (IPB 2.3.4/2.3.6) via a third party bridge library (IPBWI 2.07), and I began seeing the string NOT FOUND at the top of the web-page output. How can I turn that message off? I narrowed it down to a call to class_exists(...) in IPB. The call is working correctly, except for the p...

Login with Kohana auth module - what am I doing wrong?

I'm trying to login with the following controller action, but my login attempt keeps failing (I get the 'invalid username and/or password' message). What am I doing wrong? I also tried the other method given in the examples in the auth documentation, Auth::instance()->login($user->username, $form->password);, but I get the same result....

Catch database exception in Kohana

I'm using Kohana 2. I would like to catch a database exception to prevent an error page when no connection to the server can be established. The error displayed is system/libraries/drivers/Database/Mysql.php [61]: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', syste...

Kohana and Javscript path

Hi! I have a following Kohana setup: All my files are placed under 'public_html/koh' My js files are placed under 'public_html/koh/media/js/' I use html::script helper to include those javascript files which generates me following html code: <script type="text/javascript" src="/koh/media/js/site.js"></script> In my js I access one ...

Return via an abstract protected function?

I'm looking at the auth class in Kohana 3 as well as a login script. When the login page calls the login function of the auth class, it is returned via a protected abstract function _login. Why would you do that out of curiosity? I can't seem to understand what would really be the difference since you'd be returning the same data eith...

In Kohana 3 Is it possible to use Controller_REST and Controller_Template together?

Right now I'm using Controller_Template would like to have RESTful URLs though, is it possible to use both the controllers together somehow? Thanks. ...

Problem with DOMPDF and Kohana 3

I have used DOMPDF many times before successfully, however outside of the Kohana Framework. I created a module for DOMPDF and called it simply pdf. Here is it's code. class Pdf { private $domPdfInstance; public function __construct($html) { if ( ! class_exists('DOMPDF', FALSE)) { // Load DOMPDF ...

Database design MySQL using foreign keys

I'm having some a little trouble understanding how to handle the database end of a program I'm making. I'm using an ORM in Kohana, but am hoping that a generalized understanding of how to solve this issue will lead me to an answer with the ORM. I'm writing a program for users to manage their stock research information. My tables are...

Suggestions for performance improvement surrounding sending email notifications?

It takes around a couple of seconds for my app to execute the code to send an email right now on a test server with nothing much else running. Not sure if this is typical/expected. I'm also using the php framework Kohana's email helper and not php's mail directly out of convenience if that matters. Is it always just better to schedule a ...

How can I skip headers in Kohana 3 and just get raw output from a route?

I have a method that returns a PDF file using DOMPDF. It sends all the right headers. It is generated on the fly (not stored on the server anywhere). I now have to attach this PDF to outgoing emails. I did this in Kohana 3 $routeUrl = Route::get('secure_view_pdf')->uri(array('id' => $id)); $response = Request::factory(...

Where are Kohana config files?

I've just installed Kohana 3.0.4.2 and I have run the index.php file successfully. According to the documentation, the next step is to edit the config files in the application/config folder. I have that folder but there are no files in it! I downloaded the package again to make sure it wasn't corrupted, but the same problem exists. W...

Kohana ORM get one record in many-to-many relationship

Hi Guys, I've got two tables (items / tags). Item has and belongs to many tags - tag has and belongs to many items. It's no problem for me to fetch all related tags like: $item = ORM::factory('item', 4); foreach($item->tags as $tag){....} But how can i fetch only one... and maybe a specific one? Thanks in advance! ...

When sending headers to download a PDF, Safari appends .html

Here is the request and response headers http://www.example.com/get/pdf GET /~get/pdf HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-E...

Kohana - Facebook app URL

Hi Guys, I'm developing my first facebook app on kohana 2.3.x at the moment and I noticed that a usual app url should look like this: http://apps.facebook.com/{my_app}/{controller}/{method} But in my app it shows the real url. http://mydomain.com/{controller}/{method} Any idea how to fix that in Kohana? Thanks in advance! ...