E
E
entermix2015-03-12 16:58:51
Kohana
entermix, 2015-03-12 16:58:51

What is the correct way to instantiate a class in Kohana?

I install the package https://packagist.org/packages/sunhater/kcfinder in Kohana 3.3 using composer:
In the root of the site I execute the commands:
curl -s http://getcomposer.org/installer | php
php composer.phar require sunhater/kcfinder
6ecefc647173462d9c67bedd855af00a.png
In bootstrap.php, before loading the module, I add:
require('vendor/autoload.php');
I try to use the class in the controller (I call it the way it is called in browse.php file of the kcfinder plugin):

$browser = "kcfinder\\browser"; // To execute core/bootstrap.php on older
$browser = new $browser();      // PHP versions (even PHP 4)
$browser->action();

При переходе на нужный екшн получаю ошибку:
accc283da4244363a0b8ef8d547573e8.png
How to instantiate a class correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Semenko, 2015-03-12
@abler98

Maybe you need it like this?

$browser = new \sunhater\kcfinder\browser();
$browser->action();

A
Alexey, 2015-03-12
@rdifb0

There is no autoload package in composer.json. And in the browse.php file there is a line require "core/bootstrap.php";
Add it to your autoload in composer.json.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question