Home > Article > PHP Framework > Record how thinkphp5.1 uses Topsdk\Topapi (picture and text)
This article is provided by the thinkphp tutorial column to introduce you to tp5.1 related knowledge, which mainly records how tp5.1 uses Topsdk\Topapi (docking with Taobao open platform). I hope it will be helpful to friends who need it. Helps!
1. The company has a project that needs to be connected to the Taobao open platform. First, apply for an account, create an application, and download the corresponding SDK;
Taobao will generate the corresponding api interface SDK based on the corresponding application permissions. You may need a certain If you have the ability to interface an interface, but there is no corresponding class in the sdk, you must first apply for the corresponding interface permission;
2. After downloading it directly (without using composer), it is not easy to put it in the vendor directory and use the vendor function to introduce it. , and later found that tp5.1 has abandoned the vendor function, and the loader class is not easy to use.
2.1 When downloading directly, it is as shown in the figure
#3. We want to automatically load and use the corresponding classes directly, and return to using the composer package; go to packagist.org/ Search Topsdk\Topapi; find its package version v1.1
4. Add the Topsdk\Topapinq package to composer.json in the project (you can find a new tp5.1 first) Test) As shown in the figure
5. Open the command line and execute composer install or update
6. Create a controller test
7. Test OK Delete the package just downloaded by composer (it is only for basic capability classes), and copy the package originally downloaded in the application to the vendor directory.
8. During use, it may be reported that the xxx class cannot be found. Please modify the file class name.
9. For other pitfalls, the documentation examples may be inconsistent with the SDK code. Please watch and modify it yourself
The above is the detailed content of Record how thinkphp5.1 uses Topsdk\Topapi (picture and text). For more information, please follow other related articles on the PHP Chinese website!