Chuyển đến nội dung chính

Add external lib to vendor Magento 2

Magento 2 use autoload implement Code style PSR-4


You can add any custom source lib much easier by add require autoload

1. Upload lib files to vendor dir

2. Add file autoload.php in /vendor/lib-folder/autoload.php with content
define('FACEBOOK_SDK_V4_SRC_DIR', '/src/Facebook/');
require __DIR__ . '/src/Facebook/autoload.php';
3. Save and now you can call lib from anywhere
like this
---- Injection from constructor and call instance in class
\Facebook\Facebook

Nhận xét

Bài đăng phổ biến từ blog này

Fix XML Validate of PhpStorm in magento 2

PhpStorm 9 with magento 2 dev-1.0.0beta Follow this steps Step1 Step2 Step3 Step4 Step5 Step6 Thanks for visit , share this post if you like