Home >PHP Framework >ThinkPHP >How to install ThinkPHP plug-in in Weiqing
1. Download the ThinkPHP plug-in
Before starting to use the ThinkPHP plug-in, we should first download its compressed package from the official website and extract it to a local directory middle. 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
After uploading the plug-in, we need to install the plug-in on Weiqing'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
Once the ThinkPHP plug-in is installed, we can use the functions it provides in WeQing. Normally, we can define corresponding methods in the plug-in's controller for use by other modules or plug-ins. For example, we can define the following method in the controller of the plug-in:
public function hello() { return 'hello,thinkphp'; }
Then, in the Controller of other modules or plug-ins, the method can be called as follows:
$thinkphpPlugin = $this->createPlugin('wxapp_thinkphp_plugin'); echo $thinkphpPlugin->hello();
In calling createPlugin
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
.
The above is the detailed content of How to install ThinkPHP plug-in in Weiqing. For more information, please follow other related articles on the PHP Chinese website!