PHP extension package: a brief introduction to the extension package that can replace PHP native functions

不言
Release: 2023-04-03 18:54:01
Original
2020 people have browsed it

The content of this article is about PHP expansion packages: a brief introduction to expansion packages that can replace PHP native functions. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .

Although programmers are making wheels all the time, there are also differences in efficiency in making wheels. Only by using good wheels can you create a good "??"

guzzlehttp/guzzle

composer require guzzlehttp/guzzle

You can use guzzlehttp to completely replace curl, file_get_content, fopen and other functions. This expansion pack is extremely easy to use. Let’s look at the comparison in terms of code size.

php_curl

 "coder", "password" => "12345" ); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); //执行命令 $data = curl_exec($curl); //关闭URL请求 curl_close($curl); //显示获得的数据 print_r($data);
Copy after login

guzzlehttp

use GuzzleHttp\Client; $client = new GuzzleHttp\Client(); $response = $client->request('POST', 'http://www.baidu.com', [ 'form_params' => [ 'username' => 'coder', 'password' => '12345' ] ]); print_r($response);
Copy after login

jenssegers/date

composer require jenssegers/date

Use this extension package to let the php program The implementation of date-related requirements by employees is more concise and simple. Please see the comparison below

php_date

date("Ym", strtotime("-1 day")); //获取前一天的日期 date("Ym", strtotime("+1 day")); //获取后一天的日期
Copy after login

jenssegers_date

(new Date('-1 day'))->format ('Ym'); // 获取前一天的日期 (new Date('+1 day'))->format ('Ym'); //获取后一天的日期
Copy after login

It is obvious that the new method is more intuitive for date processing. Of course, this is a simple application, and it will be more advantageous in complex date calculations.

chumper/zipper

composer require chumper/zipper
Using this package can simplify the complexity of using the zip function of PHP itself

php_zip

'; }else { echo $file_name . '
'; $file_size = zip_entry_filesize($zip); $file = zip_entry_read($zip, $file_size); file_put_contents($save_path, $file); zip_entry_close($zip); } } } } zip_close($resource);
Copy after login

chumper/zipper

Zipper::make('test.zip')->folder('test')->extractTo('foo');
Copy after login

It’s so obvious that I don’t think I need to explain anything.

anchu/ftp

composer require anchu/ftp
This package can simplify the process of php's own ftp upload code

php_ftp


        
Copy after login

anchu/ ftp

Config::set('ftp.connections.key', array( 'host' => '', 'username' => '', 'password' => '', 'passive' => false, 'secure' => false, )); FTP::uploadFile($fileFrom,$fileTo,$mode)
Copy after login

Related recommendations:

redis PHP extension package installation method

##php Install xdebug extension, phpxdebug extension

php extension and embedding--c extension development helloworld

The above is the detailed content of PHP extension package: a brief introduction to the extension package that can replace PHP native functions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!