How to implement custom php library in magento2 inside vendor directory and use it in module

by Vinay Sikarwar   Last Updated August 15, 2018 06:09 AM

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.


Tags : magento2

Answers 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.

August 15, 2018 05:39 AM

Related Questions

Custom Price in storefront

Updated January 28, 2019 09:09 AM

Cart Price Rules having issues

Updated October 01, 2018 18:09 PM

Can Magento2 Enterprise see admin revenue

Updated November 21, 2018 13:09 PM

Magento 2.2 Not Loading theme and blocks

Updated January 11, 2018 02:09 AM