2020年最新整理20个必备PHP开源类库,武装生产力

2023-05-26 0 899

2020年一季度已结束,PHP依然是Z好的词汇,所推荐20个必不可少的PHP开放源码C#,只所推荐名列第三第三的C#,其它坎奇斯的就不考量了,很多C#早已破败,所推荐就所推荐这条街最靓的仔。责任编辑全面覆盖了架构、单元测试、文档(excel、pdf)、笔记、应用领域等最常见的C#,名列不分相继,请珍藏,说不定你罢了。

1、统计数据表单 Excel处置C#PhpSpreadsheet

Github star 8.5K,所推荐指数 ★★★★☆ Github门牌号:https://github.com/PHPOffice/PhpSpreadsheet

PhpSpreadsheet是新一代的PHP excle类别,在重新命名内部空间、PSR规范、选用捷伊PHP词汇优点,老的PHPExcel 早已好久没有 保护了。

<?php require vendor/autoload.php; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue(A1, Hello World !); $writer = new Xlsx($spreadsheet); $writer->save(hello world.xlsx);

2、程序代码架构 phpunit

Github star 16.3k,所推荐成分股 ★★★★☆ Github门牌号:https://github.com/sebastianbergmann/phpunit PHPunit官方网站:https://phpunit.de/

有鉴于杰出的潜能,许多开放源码架构早已内建此程序代码C#,PHPUnit 9早已全力支持PHP7.3和PHP7.4。

3、银河系第三架构 Laravel

Github star 21.4k,所推荐成分股 ★★★★★ Github门牌号:https://github.com/laravel/framework一个架构的杰出不仅是从Google成分股,github star,相关的生态非常重要。因为有一个好的生态,在各应用领域领域会有解决方案,比如你想用Elasticsearch、想用serverless,总有程序猿帮你解决了。

4、统计数据库ORM架构Doctrine

Github star 21.4k,所推荐成分股 ★★★☆☆ Github门牌号:https://github.com/doctrine/orm 官方网站:https://www.doctrine-project.org/projects/orm.html如果你不像使用任何架构,只想使用统计数据库相关操作,Doctrine是个合适的选择。对象关系映射器(ORM)和统计数据库抽象层(DBAL)底层C#,像Lavaral、Symfony都有代码集成,目前最稳定为2.7.3,下个大版本3.0马上也要到来。

5、Aws 服务 aws-sdk-php

Github star 4.8K,所推荐成分股★★★☆☆ Github门牌号: https://github.com/aws/aws-sdk-php 如果你的服务使用的是 Aws,那这个全家桶不错。

6、笔记管理 Monolog

Github star 17.6K,所推荐成分股★★★★★ Github门牌号:https://github.com/Seldaek/monologMonolog可以把你的笔记发送到文档,sockets,收件箱,统计数据库和各种web服务器上。一些特殊的组件可以给你带来特殊的笔记策略,包括Symfony 、Laravel、 CakePHP等诸多知名php架构都内建了Monolog

举例:

<?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger(name); $log->pushHandler(new StreamHandler(path/to/your.log, Logger::WARNING)); // add records to the log $log->warning(Foo); $log->error(Bar);

7、格式化php的代码 PHP-CS-Fixer

Github star 9.1K,所推荐成分股★★★☆☆ Github门牌号:https://github.com/FriendsOfPHP/PHP-CS-Fixer

php-cs-fixer fix /path/dir 文档目录或者指定文档

8、统计数据填充工具faker

Github star 24.1K,所推荐成分股★★★★★ Github门牌号: https://github.com/fzaninotto/Faker凡是用过Faker的,那绝对是神器,没有统计数据再也不用操心了。Faker是一个很神奇的项目,会自动生成拟真的统计数据,包括用户资料、长文本、IP、日期等等,在网站上线前测试时非常好用。

<?php // use the factory to create a Faker\Generator instance $faker = Faker\Factory::create(); // generate data by accessing properties echo $faker->name; // Lucy Cechtelar; echo $faker->address; // “426 Jordy Lodge // Cartwrightshire, SC 88120-6700” echo $faker->text;

9、邮件服务PHPmailer

Github star 15.1K,所推荐成分股★★★★☆ Github门牌号:https://github.com/PHPMailer/PHPMailerPHP界的扛把子,使用最广泛的PHP邮件C#, WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla都集成,全力支持50多个语言,发邮件,抄送,发送附件,毫无疑问,首选首选。来看用例。

<?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; // Load Composers autoloader require vendor/autoload.php; // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true); try { //Server settings $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = smtp1.example.com; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = [email protected]; // SMTP username $mail->Password = secret; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above //Recipients $mail->setFrom([email protected], Mailer); $mail->addAddress([email protected], Joe User); // Add a recipient $mail->addAddress([email protected]); // Name is optional $mail->addReplyTo([email protected], Information); $mail->addCC([email protected]); $mail->addBCC([email protected]); // Attachments $mail->addAttachment(/var/tmp/file.tar.gz); // Add attachments $mail->addAttachment(/tmp/image.jpg, new.jpg); // Optional name // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = Here is the subject; $mail->Body = This is the HTML message body <b>in bold!</b>; $mail->AltBody = This is the body in plain text for non-HTML mail clients; $mail->send(); echo Message has been sent; } catch (Exception $e) { echo “Message could not be sent. Mailer Error: {$mail->ErrorInfo}”; }

10、html转为PDFC#dompdf

Github star 7.1K,所推荐成分股★★★★☆ Github门牌号:https://github.com/dompdf/dompdf做企业应用领域的,类似文档处置,html转为pdf是常见场景。dompdf是一个CSS 2.1兼容的HTML布局和呈现引擎,用PHP编写。它是一个样式驱动的呈现程序:它将下载和读取外部样式表、内联样式标记和单个HTML元素的样式属性。它还全力支持大多数表示HTML属性。

// reference the Dompdf namespace use Dompdf\Dompdf; // instantiate and use the dompdf class $dompdf = new Dompdf(); $dompdf->loadHtml(hello world); // (Optional) Setup the paper size and orientation $dompdf->setPaper(A4, landscape); // Render the HTML as PDF $dompdf->render(); // Output the generated PDF to Browser $dompdf->stream();

11、Debug工具xdebug

Github star 2.1K,所推荐成分股★★★★☆ Github门牌号:https://github.com/xdebug/xdebug Xdebug是一个PHP调试工具。它提供了步骤调试和一系列开发辅助工具,如堆栈跟踪、代码分析器、将脚本的完整执行转储到文档的功能等。

php run-xdebug-tests.php

12、自动生成文档 phpdocumentor

Github star 2.6K,所推荐成分股★★★★☆ Github门牌号:https://github.com/phpDocumentor/phpDocumentor 目前稳定版v2.0,PHPDocumentor是一个用PHP写的工具,对于有规范化注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。

phpdoc run -d <SOURCE_DIRECTORY> -t <TARGET_DIRECTORY>

13、Http请求curlC# Guzzle

Github star 19.5K,所推荐成分股★★★★★ Github门牌号:https://github.com/guzzle/guzzle Guzzle是一个PHP HTTP客户端,它使发送HTTP请求变得容易,与web服务的集成变得简单。Guzzle是目前Z好用的curlC#。

$client = new \GuzzleHttp\Client(); $response = $client->request(GET, https://api.github.com/repos/guzzle/guzzle); echo $response->getStatusCode(); // 200 echo $response->getHeaderLine(content-type); // application/json; charset=utf8 echo $response->getBody(); // {“id”: 1420053, “name”: “guzzle”, …} // Send an asynchronous request. $request = new \GuzzleHttp\Psr7\Request(GET, http://httpbin.org); $promise = $client->sendAsync($request)->then(function ($response) { echo I completed! . $response->getBody(); }); $promise->wait();

14、日期处置Carbon

Github star 14.5K,所推荐成分股★★★★★ Github门牌号:https://github.com/briannesbitt/Carbon官方网站:https://carbon.nesbot.com/

<?php use Carbon\Carbon; printf(“Now: %s”, Carbon::now()); printf(“Right now is %s”, Carbon::now()->toDateTimeString()); printf(“Right now in Vancouver is %s”, Carbon::now(America/Vancouver)); //implicit __toString() $tomorrow = Carbon::now()->addDay(); $lastWeek = Carbon::now()->subWeek();

15、图片处置类 Image

Github star 10.9K,所推荐指数★★★☆☆ Github门牌号:https://github.com/Intervention/imageIntervention Image是一个PHP图像处置和操作库,为创建、编辑和合成图像提供了一种更简单、更具表现力的方式。Laravel内部已集成。其实飞哥更为所推荐的做法是是云储存,比如阿里云OSS,腾讯COS,把处置这些的资源释放出来。

// open an image file $img = Image::make(public/foo.jpg); // resize image instance $img->resize(320, 240); // insert a watermark $img->insert(public/watermark.png); // save image in desired format $img->save(public/bar.jpg);

16、功能齐全的后台管理系统 laravel-admin

Github star 8.7K,所推荐成分股★★★★☆ Github门牌号:https://github.com/z-song/laravel-admin 一个功能齐全的管理后台,集成权限,统计数据处置,代码生成等。

17、搜索引擎 elasticsearch-php

Github star 4.1K,所推荐成分股★★★☆☆ Github门牌号:https://github.com/elastic/elasticsearch-php

18、词库的中文转拼音

Github star 3.4K,所推荐成分股★★★☆☆ Github门牌号:https://github.com/overtrue/pinyin基于 CC-CEDICT 词典的中文转拼音工具,更准确的全力支持多音字的汉字转拼音解决方案

use Overtrue\Pinyin\Pinyin; // 小内存型 $pinyin = new Pinyin(); // 默认 // 内存型 // $pinyin = new Pinyin(\\Overtrue\\Pinyin\\MemoryFileDictLoader); // I/O型 // $pinyin = new Pinyin(\\Overtrue\\Pinyin\\GeneratorFileDictLoader); $pinyin->convert(带着希望去旅行,比到达终点更美好); // [“dai”, “zhe”, “xi”, “wang”, “qu”, “lyu”, “xing”, “bi”, “dao”, “da”, “zhong”, “dian”, “geng”, “mei”, “hao”] $pinyin->convert(带着希望去旅行,比到达终点更美好, PINYIN_TONE); // [“dài”,”zhe”,”xī”,”wàng”,”qù”,”lǚ”,”xíng”,”bǐ”,”dào”,”dá”,”zhōng”,”diǎn”,”gèng”,”měi”,”hǎo”] $pinyin->convert(带着希望去旅行,比到达终点更美好, PINYIN_ASCII_TONE); //[“dai4″,”zhe”,”xi1″,”wang4″,”qu4″,”lyu3″,”xing2″,”bi3″,”dao4″,”da2″,”zhong1″,”dian3″,”geng4″,”mei3″,”hao3″]

19、Swagger生成API文档

Github star 3.5K,所推荐成分股★★★☆☆ Github门牌号:https://github.com/zircote/swagger-phpSwagger是一种简单、强大的RESTful API表现形式。其拥有地球上最大的API工具生态环境,无数程序员在几乎所有主流词汇和开发环境中添加了对Swagger的全力支持。那怎么可以少了PHP的全力支持呢。

<?php require(“vendor/autoload.php”); $openapi = \OpenApi\scan(/path/to/project); header(Content-Type: application/x-yaml); echo $openapi->toYaml();

20、微信开发easywechat

Github star 9K,所推荐成分股★★★☆☆ Github门牌号:https://github.com/overtrue/wechat 公众平台、小程序、微信支付,微信相关生态集成的SDK。

原文链接:2020年新一代重新整理20个必不可少PHP开放源码C#,民兵组织劳动生产率 – 飞哥专栏

关于作者:飞哥

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务