問題描述
該庫(kù)不需要與 magento 集成,它主要是一個(gè)與 API 通信的包裝器.
The library doesn't need to integrate with magento, it's mostly a wrapper that communicates with an API.
我希望能夠使用這個(gè)庫(kù)并從控制器或模型中進(jìn)行這些 API 調(diào)用.
I would like to be able to use this library and make these API calls from within a controller or model.
我可以把圖書館放在哪里?如何將它們添加到自動(dòng)加載器?
Where can I put the library? How do I add them to the autoloader?
推薦答案
查看網(wǎng)站根目錄中的/lib 文件夾.來(lái)自 Magento 基礎(chǔ)目錄:
Look into /lib folder in your website root directory. From Magento Base Directories:
Magento 的庫(kù)文件夾是非基于模塊的 Magento 代碼存在.這包括大量的允許 Magento 的系統(tǒng)代碼運(yùn)行,以及一些第三派對(duì)圖書館(包括 Zend框架).圖書館也是Magento 將搜索的最后一個(gè)代碼池嘗試自動(dòng)加載文件時(shí).
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.
因此,換句話說(shuō),如果您的庫(kù)支持 zend 文件命名約定 - 庫(kù)類將被 magento 自動(dòng)加載器找到并加載.否則,您可以使用 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');
這篇關(guān)于如何將第 3 方庫(kù)添加到 magento?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!