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 "??"
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.
"coder", "password" => "12345" ); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); //执行命令 $data = curl_exec($curl); //关闭URL请求 curl_close($curl); //显示获得的数据 print_r($data);
use GuzzleHttp\Client; $client = new GuzzleHttp\Client(); $response = $client->request('POST', 'http://www.baidu.com', [ 'form_params' => [ 'username' => 'coder', 'password' => '12345' ] ]); print_r($response);
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
date("Ym", strtotime("-1 day")); //获取前一天的日期 date("Ym", strtotime("+1 day")); //获取后一天的日期
(new Date('-1 day'))->format ('Ym'); // 获取前一天的日期 (new Date('+1 day'))->format ('Ym'); //获取后一天的日期
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.
composer require chumper/zipper
Using this package can simplify the complexity of using the zip function of PHP itself
'; }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);
Zipper::make('test.zip')->folder('test')->extractTo('foo');
It’s so obvious that I don’t think I need to explain anything.
composer require anchu/ftp
This package can simplify the process of php's own ftp upload code
Copy after login
Config::set('ftp.connections.key', array( 'host' => '', 'username' => '', 'password' => '', 'passive' => false, 'secure' => false, )); FTP::uploadFile($fileFrom,$fileTo,$mode)
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!