CakePHP没有找到FacebookSession类问题 [英] CakePHP FacebookSession class not found issue

查看:155
本文介绍了CakePHP没有找到FacebookSession类问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Facebook lib v4来创建一个简单的Facebook登录信息。

I'm trying use Facebook lib v4 to create a simple Facebook login.

我正在关注Facebook指南,我坚持认为,CakePHP不是找到FacebookSession类,请按照以下事实:

I'm following Facebook guide and I'm stucked at begnning, CakePHP is not finding FacebookSession class, follow below the facts:

FacebookSession类路径:

FacebookSession class path:

App/Lib/Facebook/src/Facebook

在控制器中使用:

app::uses('FacebookSession', 'Facebook/src/Facebook');

我认为问题是在这个特定的Facebook Lib,因为我使用WideImage类,

I think the Issue is in this specific Facebook Lib because I'm using WideImage class and I'm applying the same logic to use the Class and is working Perfectly.

对于记录,我使用PHP 5.4

For the record I'm using PHP 5.4

推荐答案

自定义路径/包需要注册



首先,不是 uses()工程。自定义路径/程序包需要先注册,请参阅 CakePHP:无法从应用/ Lib加载类

Custom paths/packages need to be registered

First of all that's not how App::uses() works. Custom paths/packages need to be registered first, please refer to CakePHP: unable to load class from app/Lib

还有 Lib 是第一方图书馆,第三方图书馆如Facebook SDK应该进入供应商文件夹。

Also the Lib folder is ment to hold 1st party libraries, 3rd party libraries like the Facebook SDK should go into the Vendor folder.

另请参阅 Cookbook> CakePHP文件夹结构

t /不想使用 推荐的方式,包括SDK ,也就是使用composer安装它(请务必阅读 使用Composer安装CakePHP 时使用composer),那么您必须确保您包含 autoload.php 文件,它应该像在引导

In case you can't/don't want to use the recommended way of including the SDK, that is by installing it using composer (make sure you read the notes in Installing CakePHP with Composer when using composer), then you have to make sure that you include the autoload.php file that ships with the SDK, which should be as simple as requiring it in your bootstrap

require_once APP . 'Vendor' . DS . 'Facebook' . DS . 'autoload.php';

从这里开始,您应该可以使用SDK类 ,如文档 所示。

From there on you should be able to use the SDK classes as shown in the docs.

use Facebook\FacebookSession;

FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET');

$session = new FacebookSession('access-token');

这篇关于CakePHP没有找到FacebookSession类问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆