問題描述
該庫不需要與 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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!