Home >PHP Framework >ThinkPHP >How to install ThinkPHP plug-in in WeQing
Weiqing is a very excellent PHP open source WeChat public account management system. It provides rich functions and user-friendly interface, and is deeply loved and used by the majority of developers. In WeQing, we can expand the functions of the system by installing plug-ins. Among them, the ThinkPHP plug-in is one of the most commonly used plug-ins. This article will briefly introduce how to install the ThinkPHP plug-in in Weiqing.
1. Download the ThinkPHP plug-in
First, we need to download the compressed package of the ThinkPHP plug-in from the official website and extract it to a local directory. After decompression, we can see the following file structure:
thinkphp/ ├─library/ │ └─think/ │ ├─cache/ │ ├─console/ │ ├─controller/ │ ├─core/ │ ├─crypt/ │ ├─db/ │ ├─debug/ │ ├─di/ │ ├─event/ │ ├─exception/ │ ├─lang/ │ ├─middleware/ │ ├─model/ │ ├─paginator/ │ ├─session/ │ ├─template/ │ ├─validate/ │ └─.htaccess ├─.htaccess ├─.travis.yml ├─composer.json ├─composer.lock ├─CONTRIBUTING.md ├─LICENSE.txt ├─README.md └─think
2. Upload the ThinkPHP plug-in
After downloading the ThinkPHP plug-in, we need to upload it to Weiqing. Specifically, we need to copy the thinkphp
folder to the wxapp_thinkphp_plugin
directory under Weiqing’s addons
directory, as shown below:
addons/ ├─wxapp_thinkphp_plugin/ │ └─thinkphp/ │ ├─library/ │ │ └─think/ │ │ ├─cache/ │ │ ├─console/ │ │ ├─controller/ │ │ ├─core/ │ │ ├─crypt/ │ │ ├─db/ │ │ ├─debug/ │ │ ├─di/ │ │ ├─event/ │ │ ├─exception/ │ │ ├─lang/ │ │ ├─middleware/ │ │ ├─model/ │ │ ├─paginator/ │ │ ├─session/ │ │ ├─template/ │ │ ├─validate/ │ │ └─.htaccess │ ├─.htaccess │ ├─.travis.yml │ ├─composer.json │ ├─composer.lock │ ├─CONTRIBUTING.md │ ├─LICENSE.txt │ ├─README.md │ └─think ├─config.php ├─install.php ├─logo.png └─plugin.php
Please note that after uploading the plug-in, we also need to install the plug-in on WeQing's plug-in management page. Specifically, we need to log in to the WeQing backend, enter the plug-in management page, find the plug-in named "ThinkPHP plug-in", and install it.
3. Using the ThinkPHP plug-in
After we install the ThinkPHP plug-in, we can use the functions it provides in WeQing. Generally speaking, we can define relevant controller methods in the plug-in's Controller for other modules or plug-ins to call. For example, we can define the following method in the plug-in's Controller:
public function hello() { return 'hello,thinkphp'; }
Then, in the Controller of other modules or plug-ins, we can call this method in the following way:
$thinkphpPlugin = $this->createPlugin('wxapp_thinkphp_plugin'); echo $thinkphpPlugin->hello();
In callingcreatePlugin
method, we need to specify the directory name of the plug-in to which the method belongs. In this article, we set the directory name of the ThinkPHP plug-in to wxapp_thinkphp_plugin
.
4. Summary
Through the above steps, we can easily install and use the ThinkPHP plug-in in Weiqing. Of course, in addition to ThinkPHP plug-ins, Weiqing also provides many other plug-ins for us to choose and use, such as Laravel plug-ins, Yii2 plug-ins, etc. I hope this article will be helpful to developers who are using WeQing.
The above is the detailed content of How to install ThinkPHP plug-in in WeQing. For more information, please follow other related articles on the PHP Chinese website!