Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vendor in thinkphp3.2

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to use vendor in thinkphp3.2". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use vendor in thinkphp3.2" can help you solve your doubts.

In thinkphp3.2, vendor is used to import third-party class libraries. The default import path of this method is the Vendor directory of the thinkphp system directory, the default suffix is ".php", and the syntax is "vendor (class library to be imported, base path to import, class library suffix to be imported)".

This article operating environment: Windows10 system, ThinkPHP3.2 version, Dell G3 computer.

What is the use of vendor in thinkphp3.2

Import the vendor method into the third-party class library

Third-party class library

The third-party class library refers to other class libraries except ThinkPHP framework and application project class library, which are generally provided by third-party systems or products, such as Smarty, Zend and other system class libraries.

For class libraries imported using autoloading or import methods, the ThinkPHP convention is suffixed with .class.php, and non-such suffixes need to be controlled by the parameters of import.

However, for the third type of library, since there is no such convention, the suffix can only be thought of as php. In order to facilitate the introduction of other frameworks and system class libraries, ThinkPHP specially provides the function of importing third-party class libraries. The third-party class libraries are uniformly placed under the ThinkPHP system directory / Vendor and imported using the vendor method.

Vendor method

Syntax:

Boolen vendor (class, baseUrl, ext)

Class must represent the class library to be imported, using a namespace.

BaseUrl is optional, indicating the base path of the import. If omitted, the system uses the ThinkPHP system directory / Vendor directory.

Ext is optional, indicating the imported class library suffix. The default is .php.

Unlike the import method, the default import path of the vendor method is the ThinkPHP system directory / Vendor directory, and the default suffix is .php.

Examples are as follows:

Use in the function function:

Vendor ('Phpqrcode.phpqrcode'); / * * generate QR code * @ param string $url url connection * @ param integer $size size pure number * / function qrcode ($url,$size=4) {Vendor (' Phpqrcode.phpqrcode'); if (strpos ($url, 'http') = false) {$url=' http://'.$url;} QRcode::png ($url,false,QR_ECLEVEL_L,$size,2,false,0xFFFFFF,0x000000) } after reading this, the article "how to use vendor in thinkphp3.2" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about related articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report