如何在 CakePHP 3x 中导入供应商文件 [英] How to import vendor files in CakePHP 3x

查看:19
本文介绍了如何在 CakePHP 3x 中导入供应商文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最近推出的 CakePHP 3(beta 2) 版本.我需要使用 PHP SDK 集成 Facebook 登录,但我不清楚在此版本中导入供应商文件.
在 CakePHP 2x 中,我使用了

I'm working with CakePHP 3(beta 2) version recently launched. I need to integrate Facebook Login using PHP SDKs and I'm not clear with importing vendor files in this version.
In CakePHP 2x, I had used

App::import('Vendor', 'Facebook', array('file' => 'Facebook' . DS . 'src'. DS. 'facebook.php'));

所以我需要在 CakePHP 3x 中重现相同的内容(我没有使用作曲家).
对此有任何参考吗?

So I need to reproduce the same in CakePHP 3x(I'm not using composer).
Any reference for this?

推荐答案

好吧,如果 Composer 不是一个选项,您将不得不自己加载它.您始终可以使用非常基本的 require 方法并自己创建供应商类的新实例.参考:http://book.cakephp.org/3.0/en/核心库/app.html#loading-vendor-files

Well you will have to load it yourself if composer is not an option. You can always use the very basic require method and create a new instance of the vendor class yourself. Reference: http://book.cakephp.org/3.0/en/core-libraries/app.html#loading-vendor-files

使用:

 //The following line should do the same like App::import() in the older version of cakePHP
 require_once(ROOT . 'vendor' . DS  . 'Facebook' . DS . 'src' . DS . 'facebook.php');

 $facebookApi = new facebook();

这篇关于如何在 CakePHP 3x 中导入供应商文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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