如何将第3方库添加到magento? [英] how to add a 3rd party library to magento?

查看:104
本文介绍了如何将第3方库添加到magento?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该库不需要与magento集成,它主要是与API通信的包装器.

The library doesn't need to integrate with magento, it's mostly a wrapper that communicates with an API.

我希望能够使用该库并从控制器或模型中进行这些API调用.

I would like to be able to use this library and make these API calls from within a controller or model.

我可以在哪里放置图书馆?如何将它们添加到自动加载器中?

Where can I put the library? How do I add them to the autoloader?

推荐答案

浏览网站根目录中的/lib文件夹.来自 Magento基本目录:

Look into /lib folder in your website root directory. From Magento Base Directories:

Magento的库文件夹位于 非基于模块的Magento代码存在. 这包括大量的 系统代码,使Magento能够 运行,以及第三 政党图书馆(包括Zend 框架).图书馆也是 Magento将搜索的最后一个代码池 尝试自动加载文件时.

Magento’s library folder is where non-module based Magento code lives. This include a large amount of the system code which allows Magento to run, as well as a number of third party libraries (including the Zend Framework). The library is also the last code pool Magento will search when attempting to autoload a file.

因此,换句话说,如果您的库支持zend文件命名约定-magento自动加载器将找到并加载库类.否则,您可以使用Mage :: getBaseDir(‘lib’)获取/lib目录的路径,并编写类似

So, in other words, if your library supports zend file naming convention - library classes will be found and loaded by magento autoloader. Otherwise you can get path of your /lib directory with Mage::getBaseDir(‘lib’) and write something like

require_once(Mage::getBaseDir('lib') . '/EZComponents/Base/src/base.php');

这篇关于如何将第3方库添加到magento?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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