Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Making my first Package
  • Struggling a bit trying to create a package for Rackspace Cloud Files API. I've created a folder called 'cloudfiles' in packages. bootstrap.php is as follows
    Autoloader::add_core_namespace('Cloudfiles');
    
    Autoloader::add_classes(array(
     'Cloudfiles\\CF_Authentication' => __DIR__.'/classes/cloudfiles.php',
    ));
    

    I've added the three files required of the Cloud Files into classes of the package. There's a few classes, but the first one is called CF_Authentication. In a controller I then load the package
    Package::load('Cloudfiles')
    

    Then I call
    $auth = Cloudfiles::CF_Authentication();
    

    I seem to only be able to get an error:
    ErrorException [ Error ]: Class 'Cloudfiles' not found I can't figure out where I'm going wrong. Any ideas?
  • So CF_Authentication is of course the class, not the function, so I'm now using
    Cloudfiles\CF_Authentication::authenticate()
    

    Great! But... ErrorException [ Parsing Error ]: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$'
    $auth = new Cloudfiles\CF_Authentication::authenticate();
    

    If I remove the new bit, I get ErrorException [ Error ]: Call to a member function authenticate() on a non-object instead, so I can't figure out what it's expecting when I use new?
  • Have you tried: $auth = Cloudfiles\CF_Authentication::authenticate(); or if you don't want to call it statically $cf_auth = new Cloudfiles\CF_Authentication();
    $auth = $cf_auth->authenticate();
  • That's better, but now all I seem to get is Cannot redeclare class Cloudfiles\CF_Authentication no matter what I use! There's only one instance of that class, so I don't know how I'm redeclaring it!
  • That happens when the classname & filename don't match, thus if the file is loaded but it turns out the classname in there isn't right.
  • Ohhhh the provided classes are all in the same file! Was trying to keep it as close to the original as possible. Thanks Jelmer, will try that.

Howdy, Stranger!

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

In this Discussion