Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
After deploy autoloader failing
  • I've created a Customvalidation class in app/classes with a function _validation_unique. This works fine on my local box. When I deploy to a Rackspace instance the site works in general but on the forms that use this custom validation I get the following error: InvalidArgumentException [ Error ]: Input for add_callable is not a valid object or class. For some reason it is not picking up the custom class anymore. It looks like everything transferred over fine including directory structure, naming, etc. I have noticed that logging no longer works either after deploying. File permissions set fairly open. Any ideas?
  • Try using oil to run the install script php oil refine install on your production server, that might set the permissions correctly, or tell you why it can't.
  • Thanks, gave it a try but still getting the same error. I have ownership set to the apache user and permissions to 755 which seems to work just fine. Just seems like the FuelPHP engine doesn't know where to look for the custom validator class. BTW - Using Rackspace
  • It is definitely something to do with the Autoloader having issues in the deployed environment. As soon as I explicitly add "use Customvalidation;" to the class the next error is:
    ErrorException [ Error ]: Class 'User' not found
  • How do you refer to "User" in Customvalidation? Where is this class defined? It sound very much like a namespace error...
  • Here's the section of code. It works locally. Just not after deployed.
      $user = User::find_one_by_id($this->user_id);
      $this->template->set_global('user', $user, false);
      if (Input::method() == 'POST')
      {
       $val = Validation::forge('user');
       $val->add_callable('customvalidation');
       $val->set_message('required', ':label is required.');
       $val->set_message('unique', ':label is already in use. Please enter a unique :label.');
       $val->add_field('first_name', 'First Name', 'required|max_length[255]');
       $val->add_field('last_name', 'Last Name', 'required|max_length[255]');
       $val->add_field('password', 'Password', 'min_length[3]|max_length[30]');
       $val->add_field('email', 'Email', 'required|valid_email');
       $val->add_field('skype', 'Skype', 'max_length[255]');
       if($val->run())
       {
        $updated_user = Auth::instance()->update_user(
         array(
          'first_name' => $val->validated('first_name'),
          'last_name' => $val->validated('last_name'),
          'password' => $val->validated('password'),
          'email' => $val->validated('email'),
          'skype' => $val->validated('skype')
         ),
         $user->username
        );
    
        Session::set_flash('notice', 'Profile updated');
    
        Response::redirect('today');
    
       }
       else
       {
        Session::set_flash('error', 'Error: Could not update profile');
        $data['val_error'] = $val->error();
       }
    
  • You don't by accident develop on Windows, and deploy on linux or MacOS? And if so, did you stick to the naming conventions? If not, know that a Windows filesystem is case insensitive (user.php is the same as User.php), but on Linux it isn't, causing files not to be found...
  • Yes but I don't by accident but on purpose :) I thought that might have been an issue so last night tried add_callable with different casing:
    $val->add_callable('customvalidation');
    
    $val->add_callable('Customvalidation');
    

    Or is there something else that may be affected by casing that I need to look at? Thanks!
  • That doesn't help, the autoloader forces the case of the filename. You on purpose broke FuelPHP. ;)
  • Thanks for getting me in the right direction WanWizard. Had to rename my custom validation file name to all lowercase.
  • To save you a bit of time next time: http://docs.fuelphp.com/general/coding_standards.html (see File naming).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion