How to implement custom php library in magento2 inside vendor directory and use it in module. I have moved the custom php library in vendor folder and now i want to use that library in my module. what is the way to do that.


1 Answer 1


Magento 2 uses various technologies and composer is one of them ,composer is used to manage dependency in the project the best way to add any external library without going into the code is composer, Magento have a composer.json file in its root. For adding stripe library in the vendor folder ,you just need to run this command from the command line

For This Command You Must Install Composer On Your Server ,If You Are Not Familiar With Composer Go Through This Link First : https://Getcomposer.Org/Doc/00-Intro.Md after installing the composer, goto your magento 2 root folder and run below command from the terminal :

composer require stripe/stripe-php

In the above command “stripe/stripe-php” is the package name you can found this on packagist .

after executing the above command the latest version of stripe library will be installed on your magento 2 extension and it will be autoloaded in your project .You can found the changes on two places in the magento first in the composer.json file in the magento 2 root: enter image description here and the second you will find its folder in magento 2 vendor folder in the root: enter image description here

Let me know if you have any confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.