how to add a 3rd party library to magento?(如何将第 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将第 3 方库添加到 magento?
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
