Michael Phelps
Michael Phelps

Reputation: 3601

Can't create new module .Class not Found

I create file Vv.php in htdocs\kohana\application\vv

Vv.php

class Vv{
const $r=10;
}
echo 'init';

bootstrap.php

   Kohana::modules(array(
     .....
               'vv' =>APPPATH.'vv'

        ));
echo Vv::$r //Fatal Error Class Vv not Found. 

Upvotes: 0

Views: 157

Answers (2)

Moe
Moe

Reputation: 130

If you like to create a module, you better create the vv folder in the modules folder.

htdocs\kohana\modules\vv\classes\Vv.php

next add the module into the bootstrap file

Kohana::modules(array(
   ...
   'vv' =>MODPATH.'vv'
));

After you did that your able to acces Vv

echo Vv::$r;

Upvotes: 1

D T
D T

Reputation: 1556

Is the class part of a module? If not, there is no need to load it via Kohana::modules.

What you can do is move the file to the classes folder:

htdocs\kohana\application\classes\Vv.php

And then you can access the class from your bootstrap.php file like so:

Kohana::modules(array(
    .....
));

echo Vv::r

Take a look at the autoloading support in Kohana for more information.

Also remember that class constants should not start with a $, so your Vv class will need to be:

class Vv {
    const r = 10;
}

Upvotes: 2

Related Questions