搜索
首页头条【整理推荐】值得收藏的8个实用PHP库

PHP中文网为同学们整理了github上Star比较高的8个实用的PHP库,提升开发效率。

1.pinyin(中文转拼音工具)

项目地址:https://github.com/overtrue/pinyin

基于 CC-CEDICT 词典的中文转拼音工具,更准确的支持多音字的汉字转拼音解决方案,示例代码:

se OvertruePinyinPinyin;

$pinyin = new Pinyin();

$pinyin->convert('带着希望去旅行,比到达终点更美好');
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

$pinyin->convert('带着希望去旅行,比到达终点更美好', PINYIN_UNICODE);
// ["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);
//["dai4","zhe","xi1","wang4","qu4","lv3","xing2","bi3","dao4","da2","zhong1","dian3","geng4","mei3","hao3"]

2.php-curl-class(PHP cURL 库)

项目地址:https://github.com/php-curl-class/php-curl-class

该开源项目封装了 PHP 的 cURL 库,使得发送 HTTP 请求变得简单。适用于需要 PHP 爬虫或者其它模拟 HTTP 访问的情况,示例代码:

<?php
// 获取豆瓣电影示例
require &#39;../vendor/autoload.php&#39;;
use Curl\Curl;

$curl = new Curl();
$url = "https://movie.douban.com/j/search_subjects?type=movie&tag=%E8%B1%86%E7%93%A3%E9%AB%98%E5%88%86&sort=time&page_limit=20&page_start=1";
$curl->get($url);
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
$curl->close();
var_dump($curl->getResponse());exit;

1.png

3.parsedown(Markdown 解析库)

项目地址:https://github.com/erusev/parsedown

一个小而美的 PHP 的 Markdown 解析库。该库提供了标准 Markdown 文本转化成 HTML 字符串功能,并拥有良好的文档。它的主文件只有一个,除了 PHP 版本限制必须高于 5.3 外几乎无依赖,可通过 composer 引入,也可以直接使用 Parsedown.php 文件。该项目中使用大量正则表达式,可作为学习正则表达式的示例,并且有完整的单元测试。示例代码:

$Parsedown = new Parsedown();
echo $Parsedown->text(&#39;Hello _Parsedown_!&#39;); # prints: <p>Hello <em>Parsedown</em>!</p>

4.dompdf(HTML 转 PDF)

项目地址:https://github.com/dompdf/dompdf

一个 HTML 转 PDF 的 PHP 库。示例代码:

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(&#39;hello world&#39;);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper(&#39;A4&#39;, &#39;landscape&#39;);

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

5.PHPWord(电商平台)

项目地址:https://github.com/PHPOffice/PHPWord

提供了读/写多种文档文件格式的 PHP 库。支持 Microsoft Office、富文本(RTF)等文档格式

<?php
require_once &#39;bootstrap.php&#39;;

// 新建文档
$phpWord = new \PhpOffice\PhpWord\PhpWord();

// Adding an empty Section to the document...
$section = $phpWord->addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
    &#39;"Learn from yesterday, live for today, hope for tomorrow. &#39;
        . &#39;The important thing is not to stop questioning." &#39;
        . &#39;(Albert Einstein)&#39;
);

6.easy-sms(短信发送 )

项目地址:https://github.com/overtrue/easy-sms

短信发送 PHP 组件。特点:

  • 支持目前市面多家服务商

  • 一套写法兼容所有平台

  • 简单配置即可灵活增减服务商

  • 内置多种服务商轮询策略、支持自定义轮询策略

use Overtrue\EasySms\EasySms;

$config = [
    // HTTP 请求的超时时间(秒)
    &#39;timeout&#39; => 5.0,

    // 默认发送配置
    &#39;default&#39; => [
        // 网关调用策略,默认:顺序调用
        &#39;strategy&#39; => \Overtrue\EasySms\Strategies\OrderStrategy::class,

        // 默认可用的发送网关
        &#39;gateways&#39; => [
            &#39;yunpian&#39;, &#39;aliyun&#39;,
        ],
    ],
    // 可用的网关配置
    &#39;gateways&#39; => [
        &#39;errorlog&#39; => [
            &#39;file&#39; => &#39;/tmp/easy-sms.log&#39;,
        ],
        &#39;yunpian&#39; => [
            &#39;api_key&#39; => &#39;824f0ff2f71cab52936axxxxxxxxxx&#39;,
        ],
        &#39;aliyun&#39; => [
            &#39;access_key_id&#39; => &#39;&#39;,
            &#39;access_key_secret&#39; => &#39;&#39;,
            &#39;sign_name&#39; => &#39;&#39;,
        ],
        //...
    ],
];

$easySms = new EasySms($config);

$easySms->send(13188888888, [
    &#39;content&#39;  => &#39;您的验证码为: 6379&#39;,
    &#39;template&#39; => &#39;SMS_001&#39;,
    &#39;data&#39; => [
        &#39;code&#39; => 6379
    ],

7.YOURLS(短网址生成)

项目地址:https://github.com/YOURLS/YOURLS

完全免费的短网址服务。采用 PHP 编写的短网址服务,它完全开源可自行搭建服务,支持数据统计、地理位置、可视化等功能。

2.gif

8.php-console(PHP 命令行应用库)

项目地址:https://github.com/inhere/php-console

使用简单,功能全面的 PHP 命令行应用库。提供控制台参数解析、命令运行、颜色风格输出、 用户信息交互等功能

3.png

开班通知:

php中文网第《22期PHP线上直播班》正式开始报名了!

4.png

授课形式:

1.零基础开始,前端到后端,系统的学习!

2.直播同步录播,内部群,老师作业批改,辅导解答,督促学习

限额活动:

1.前50名报名同学,即赠送三部实战课程,先到先得,送完为止!

2.报名即赠送一套完整PHP课程(超值),课前学习!(限前10名)

报名咨询↓↓↓

QQ报名:27220243(钟老师)

微信报名:phpcn01(月月老师)

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)