Monday, January 25, 2016

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

No comments:

Post a Comment