Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Ningauth package problem
  • Hi, I'm busy with implementing ninjauth in my project.
    When I go to the site '/auth/register' I get an error:
    Fatal error: Call to undefined method Shopify\Session::get() in path/to/project/fuel/packages/ninjauth/classes/controller.php on line 32
    

    Shopify is a package I made myself to communicate with the shopify API. Anyone got a clue what could be wrong?
    Cheers, Harold
  • You're not using namespaces properly. When you call classes from other then the current namespace, you have to prefix them. For Fuel's classes, they all live in the global namespace, so you have to use
    $var = \Session::get();
    
    if the code you use this in is namespaced. (it might also be a bug in ninjauth).
  • Mhmm,.. probably is a mistake in my package. I've changed this: https://github.com/Shopify/shopify_php_api To a fuel package:
    https://github.com/hsleewis/fuel-shopify It only gives me an error on pages where I try to do something with ninjauth. Do you see anything wrong in my package? Cheers, Harold
  • In your bootstrap, you add the 'Shopify' namespace to the core, which means all classes defined in this namespace will become part of the global namespace. And this will lead to class name collisions. For example, your classes/shopify.php defines a class called 'Session'. By adding this to the global namespace, you effectively overwrite the core session class. Which is why Ninjauth complains, it talks to the wrong session. Only use Autoloader::add_core_namespace() if you really want to add classes to the global namespace, for example if your package extensions core classes.
  • Thanks! that was it, although ninjauth is not working, the error is gone :-)

Howdy, Stranger!

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

In this Discussion