robertbyrnes/dir2db 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

robertbyrnes/dir2db

Composer 安装命令:

composer require robertbyrnes/dir2db

包简介

Uses PHP recursive iterator classes and regex iterator class to recursively search directories for .php files.

README 文档

README

dir2db!

dir2db

  • Uses PHP recursive iterator classes and regex iterator class to recursively search directories for .php files.

  • Any file extension may be searched for, or a group of them by passing in regex. See help description (run dir2db.php in cmd)

  • Certain named directories may be excluded from the search, again by passing in regex through cmd (see help in dir2db.php)

Setup

Install via git clone https://github.com/RobertByrnes/dir2db.git then cd into package root directory and run composer deploy-ini

Use dir2db.sql to install file_contents table to a mySQL database.

For example run mysql -u {$databaseUser} -p {$databaseName} < dir2db.sql

Edit ./private/local.ini to include correct database credentials.

Useage

In CMD/terminal type 'php dir2db.php', this will show the help menu:

    /*** ARGUMENTS ***/
    Required arguments:
        -p path, e.g. c:/wamp/www/
    Optional arguments: 
        -r regex, to filter file search to only include certain file extension. Default: /\.(?:php)$/
        -e exclusions, directories ommited during search e.g. vendor|node_modules|private *Must include pipe*
        -h help, prints this help message.";

Examples

  1. php dir2db.php -p c:/wamp/www/repositories
  2. php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt)$/"
  3. php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt)$/" -e vendor|node_modules
  4. php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt|ini|sql)$/" -e vendor|node_modules
  • Example 1 will search all directories within repositories for php files
  • Example 2 will search for .txt file within repositories
  • Example 3 as example 2, additionally excluding anything within directories named 'vendor' or 'node_modules'
  • Example 4 demonstrates using the regex to include multiple file extensions

Memory Limit!

If you see a fatal exception - Allowed Memory Limit re-run your command explicity as shown below:

  • php .\dir2db.php -p c:/dir2db -r "/\.(?:jpg|png|pdf|php)$/" -e "vendor|node_modules"
  • php -d memory_limit=-1 .\dir2db.php -p c:/dir2db -r "/\.(?:jpg|png|pdf|php)$/" -e "vendor|node_modules"

The -d memory_limit=-1 will tell php to ignore the memory limit whilst executing this process.

A note on Binary file types

  • The following binary file types are supported:
  • 'pdf', 'jpg', 'jpeg', 'png', 'gif', 'svg', 'ico', 'bmp', 'tiff', 'tif', 'webp'
  • file contents for these files will be stored in the binary_file_content database column which is of LONGBLOB type.
  • Files not in this list are stored in the file_content column which is of LONGTEXT type.

FileFinder Trait

The FileFinder trait uses PHP's recursive iterator classes to search for files in a directory structure returning an array of results.

Usage

To use the FileFinder trait, call the fileFinder method with the following parameters:

  • $path - The path to the directory you want to search
  • $fileFilter (optional) - A regex to find PHP file extensions
  • $directoryFilter (optional) - Directory names to exclude from the search

The fileFinder method will then return an array of results.

Files!

robertbyrnes/dir2db 适用场景与选型建议

robertbyrnes/dir2db 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 robertbyrnes/dir2db 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 robertbyrnes/dir2db 我们能提供哪些服务?
定制开发 / 二次开发

基于 robertbyrnes/dir2db 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2021-04-19