如何在 CodeIgniter 中包含外部库? [英] How do I include external Libraries in CodeIgniter?

查看:32
本文介绍了如何在 CodeIgniter 中包含外部库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 codeigniter 的新手,我正在尝试将亚马逊的 FPS 集成到我的页面中.Amazon FPS 有很多库和模型,我需要包含这些库和模型才能进行适当的调用.

I'm new to codeigniter, and I'm trying to integrate amazon's FPS into my page. There are a bunch of libraries and models that go with Amazon FPS, which I would need included to make the appropriate calls.

如何将它们包含在 CodeIgniter 中?

How do I include them in CodeIgniter?

我尝试将整个 Amazon 文件夹放在 system/libraries 目录中,然后尝试使用 $this->load->library( 'Amazon/FPS/Client' ) 包含库;但是,我在那里遇到了相对路径的问题,因为 Client.php 包含语句 require_once ('Amazon/FPS/Interface.php');...在同一个文件夹中.

I tried placing the entire Amazon folder inside the system/libraries directory, and then tried including libraries with $this->load->library( 'Amazon/FPS/Client' ); However, I run into problems with the relative path there, because Client.php contains the statement require_once ('Amazon/FPS/Interface.php'); ... which is in the same folder.

必须有更好的方法来完成所有这些 - 任何人都可以帮忙吗?

There has to be a better way to do all this - can anyone please help?

谢谢!!

推荐答案

没有什么能阻止您直接包含类并使用它们,但您会在普通 PHP 设置中这样做.如果它适用于 PHP,它也适用于 CodeIgniter.

There is nothing stopping you from directly including classes and working with them however you would in a vanilla PHP setup. If it works in PHP it will work in CodeIgniter.

include(APPPATH.'libraries/Amazon/FPS/Interface.php');

这篇关于如何在 CodeIgniter 中包含外部库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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