PHPackages                             dongdavid/utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dongdavid/utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dongdavid/utils
===============

工具类

1.2.1(5y ago)39MITPHP

Since Sep 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/DongDavid/utils)[ Packagist](https://packagist.org/packages/dongdavid/utils)[ RSS](/packages/dongdavid-utils/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

 utils
=======

[](#-utils-)

 工具类库.

Installing
----------

[](#installing)

```
$ composer require dongdavid/utils ^1.2 -vvv
```

Require
-------

[](#require)

- ext-imageMagick

使用二维码还需要以下两种依赖(phpqrcode 的源码里面错误可真是多)

- ext-zlib
- ext-gd

Usage
-----

[](#usage)

```
use dongdavid\Utils\Poster;

$poster = new Poster();
// 开启严格模式 默认开启，开启后图片或文字不能超出底图，超出会抛出错误
$poster->setStrict(true);

// 生成圆形头像

$poster->pic('./pic.png',Poster::PIC_CIRCULAR)->writeImage('./save.png');

// 生成二维码
// 有logo
$poster->setQrcode('https://www.dongdavid.com','./save.png','./logo.png');
// 无logo
$poster->setQrcode('https://www.dongdavid.com','./save.png');

// 生成海报
// 添加图片的起始坐标是图片的左上角坐标
// 添加文字的起始坐标是文字的左下角坐标，不论文字多大多粗，其左下角坐标都不会变
        // 设置背景图片
$poster->setImgBackground('./beijing.png')
        // 向海报上添加图片good_img 起始坐标为 (0,44) 添加的图片长宽为 600,800
        ->addImage('./good_img.jpeg', 0, 44, 600, 800)
        // 向海报上添加图片good_img 起始坐标为 (15.5,875) 添加的图片长宽为 72,72
        ->addImage('./user_pic.png', 15.5, 875, 72, 72)
        // 写入文字 包括中文 自带了字体文件 PingFang-SC-Bold.ttf
        // ->setFont('./xxx.ttf')
        ->addText('自带字体文件能写入中文',50,800,20,'black')
        // 添加线条， 如划线价
        ->addLine(0,0,30,30)
        // 保存海报到本地
        ->save('./poster.png');

// 根据限定长度、字体大小，将文本内容拆分为多行
$line = $poster->setEmptyBackground(1000, 900)
               ->splitText('输入的文本内容oajdewo239023嗷嗷',16,300);

// 获取文本在图片中的长宽
$line = $poster->setEmptyBackground(1000, 900)
               ->getTextInfo('文本内容',32);
```

Test
----

[](#test)

```
#本地调试
git clone https://github.com/DongDavid/utils
mkdir utils-test
cd utils-test
composer init
composer config repositories.utils path ../utils
composer require dongdavid/utils:dev-master
touch index.php
```

Changelog
---------

[](#changelog)

### v1.1.0(2020-09-07)

[](#v1102020-09-07)

修改了二维码的创建方法，移除了对endroid/qr-code的依赖，允许设定二维码的大小及容错率

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/dongdavid/utils/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/dongdavid/utils/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

3

Last Release

2073d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18623095?v=4)[DongDavid](/maintainers/dongdavid)[@DongDavid](https://github.com/DongDavid)

---

Top Contributors

[![DongDavid](https://avatars.githubusercontent.com/u/18623095?v=4)](https://github.com/DongDavid "DongDavid (22 commits)")

### Embed Badge

![Health badge](/badges/dongdavid-utils/health.svg)

```
[![Health](https://phpackages.com/badges/dongdavid-utils/health.svg)](https://phpackages.com/packages/dongdavid-utils)
```

###  Alternatives

[rami/seo-bundle

All in One Symfony Seo Bundle

321.0k](/packages/rami-seo-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
