PHPackages                             html-dom-parser/util - 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. html-dom-parser/util

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

html-dom-parser/util
====================

HtmlDomParserUtil

121PHP

Since Apr 23Pushed 7y agoCompare

[ Source](https://github.com/dengyangl/html-dom-parser-util-for-laravel)[ Packagist](https://packagist.org/packages/html-dom-parser/util)[ RSS](/packages/html-dom-parser-util/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

html-dom-parser-for-laravel
===========================

[](#html-dom-parser-for-laravel)

处理图片路径(包含了相对路径，完整路径和富文本编辑器中图片路径的处理)，一般使用阿里云的oss进行存储

### 使用该扩展前，请先安装以下扩展

[](#使用该扩展前请先安装以下扩展)

- 项目根目录composer.json文件中添加：

    "require": {

    ```
      ...
      "sunra/php-simple-html-dom-parser": "1.5.2"
      ...

    ```

    }
- 命令行运行：composer update

### 使用

[](#使用)

- 在config/app.php文件中添加以下内容：

    'providers' =&gt; \[

    ```
      ...
      HtmlDomParser\Util\HtmlDomParserUtilServiceProvider::class
      ...

    ```

    \]

    'aliases' =&gt; \[

    ```
      ...
      'HtmlDomParserUtil' => HtmlDomParser\Util\Facades\HtmlDomParserUtil::class
      ...

    ```

    \]
- 发布config配置文件(选择相应的扩展包进行发布)

    php artisan vendor:publish --provider="HtmlDomParser\\Util\\HtmlDomParserUtilServiceProvider"
- 配置config/oss.php文件中的信息(阿里云oss对应的信息)

    ###### &lt;?php

    [](#php)

    return \[

    ```
      'accessKeyId'       =>  '',

      'accessKeySecret'   =>  '',

      'endpoint'          =>  '',

      'img_path'          =>  '',

      'cut_start'         =>  0,               //截取开始位置

      'cut_end'           =>  100,             //截取结束位置

      //'oss_path_format'   =>  'Ym/d',        //Y年 m月 d日 具体参见date函数的传参，"/"代表目录

      //'bucket'            =>  '',            //存储空间

    ```

    \];
- 使用示例

    1.添加/修改数据时：

    ```
    去掉图片的域名，保留相对路径入库：

    $pic = 'http://www.xxx.com/a.jpg';

    $pic = HtmlDomParserUtil::strReplaceImgDomain($pic, true);  // /a.jpg

    去掉富文本编辑器中图片的域名，保留相对路径入库：

    $description = 'aaa';

    $description = HtmlDomParserUtil::strReplaceImgDomain($description);    // aaa

    ```

    2.读取数据的时候：

    ```
    补充图片完整的路径：

    $pic = '/a.jpg';
    $pic = HtmlDomParserUtil::strReplaceImgPath($pic, true);      // http://www.xxx.com/a.jpg

    $description = 'aaa';
    $description = HtmlDomParserUtil::strReplaceImgPath($description);    // aaa

    ```

    3.过滤图片和html标签,截取部分字符串

    ```
    $description = 'aaa';
    $description = HtmlDomParserUtil::mbSubStr($description);     // aaa

    ```

    4.获取富文本编辑器中所有图片的相对路径

    ```
    $description = 'aaa';
    $image_array = HtmlDomParserUtil::getImgPathArray($description);      // ['/b.jpg', '/c.jpg']

    ```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b02df3586441b9443ac25f17aeafe0807425d6323ce083641dc952ac354527b?d=identicon)[dengyangl](/maintainers/dengyangl)

---

Top Contributors

[![dengyangl](https://avatars.githubusercontent.com/u/23185359?v=4)](https://github.com/dengyangl "dengyangl (5 commits)")

### Embed Badge

![Health badge](/badges/html-dom-parser-util/health.svg)

```
[![Health](https://phpackages.com/badges/html-dom-parser-util/health.svg)](https://phpackages.com/packages/html-dom-parser-util)
```

###  Alternatives

[ayesh/case-insensitive-array

Class to store and access data in a case-insensitive fashion, while maintaining the integrity and functionality of a regular array.

1020.7k3](/packages/ayesh-case-insensitive-array)

PHPackages © 2026

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