Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Access Facebook SDK via Composer to My Controller
  • I am trying to use the latest Facebook SDK to work on FuelPHP. I tried getting the SDK 5 and try to convert it as a package but I can't seem to make it work.

    The next thing I did is use the composer to install the Facebook SDK (now v4 as per composer) and did what is instructed in this blog here.

    It pretty much installed the Facebook SDK on the vendor folder, but I have no idea on how to access it on my controller? Reading the link I gave above, does the classes autoloaded in the vendor can only be accessed on the package?
  • Any package you install using composer can be accessed directly by its namespace because the composer autoloader is a registered autoloader. I think, it is being called after Fuel's autoloader so that namespaces and classes configured with it will precede composer's namespace loading.
  • In short, it should be available on my controller. 

    In any case, I am taking the problem I have in this setup is not related to FuelPHP not reading my third-party package. 

  • It assumes PHP's native session management is active. Which isn't the case, since Fuel doesn't use it.

    I'd call that a bug in the SDK, it has a hardcoded dependency it shouldn't have.
  • Had a quick peek at the code.

    The SDK has a persistentData interface, and has included classes for Memory and Session storage. And an interface class, so you can design your own. So if you need persistant storage, you need to develop your own custom persistantData class that interfaces with Fuel's session storage.

     Also, I see that the Session driver has a flag that allows you to disable the session check, so I assume you can configure that somewhere. Once disabled it should also work if you enable "native_emulation" in your app's session config.

    If you autoload the Session class, you could probably even use the native session_start() method to run a native session in parallel. Fuel's Session class will make sure any data stored in the native session will be copied to Fuel's session store. In that case you probably don't even have to disable the session check.

Howdy, Stranger!

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

In this Discussion