fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Autoload Problem using Validation->add_callable #752

Closed danmatthews closed 12 years ago

danmatthews commented 12 years ago

Using the methods suggested in Validation - Classes, i created a new file and class at fuel/app/classes/login_validation.php, with the following (test) code:

public static function _validation_authenticate_user($val) {

        echo 'Authenticate Ran ok';

        return false;

    }

    public static function _validation_check_pwd($val) {

        echo 'Password ran ok';

        return false;

    }

Then, to use it with a validation sequence in a controller i used:

$v = Validation::forge();

$v->add_callable('login_validation');

But i get an exception: InvalidArgumentException [ Error ]: Input for add_callable is not a valid object or class.

I thought this may be a problem with my class syntax, or naming, but when i manually include the class into the controller using: require_once('../fuel/app/classes/login_validation.php');

Everything works as expected.

Currently working on 1.1/master.

WanWizard commented 12 years ago

You have an underscore in your classname.

According to the cascading filesystem, this class should be in app/classes/login/validation.php. Now FuelPHP can't find the class, hence the error.

danmatthews commented 12 years ago

Ah, ok, thanks. Is there any more documentation on the cascading file system and where this applies when loading classes? I apologise if this is an RTFM situation, but when following the example from the validation documentation, it can be very confusing.

WanWizard commented 12 years ago

see http://docs.fuelphp.com/general/classes.html#/classes_subdirectories