zbyrih/psr4-helper

php项目迁移至psr4助手

v0.1.1 2022-09-20 14:47 UTC

This package is auto-updated.

Last update: 2024-09-20 19:04:29 UTC


README

介绍

此工具应有助于php代码(特别是类名、命名空间、文件和文件夹)从混乱无序的项目过渡到psr-4,并通过psr-4启用composer自动加载

安装

建议通过Composer安装此助手

composer global require zbyrih/ps4-helper --dev

用法

首先,您需要在当前工作目录中创建config文件psr4helper.neon

parameters:
    path: App # folder name from current working directory
    namespace: App\ # namespace root
    expludeCaseUpdates: # names of folders that will be excluded from checking validation and changes
        - templates
        - translations
    excludePsr4CheckClassEndsWith: # end names of classes that will be excluded from the psr4 check
        - Presenter

现在,您可以使用控制台命令选项

  • --help : 显示此帮助信息
  • --list : 将多个类列在同一个文件中
  • --psr4 : 错误文件夹的类列表,通过PSR-4 info|case|missing
    • info: 显示类的不匹配和缺失文件
    • case: 不匹配的大小写
    • missing: 类的缺失文件
  • --find : 以给定值开头的具有完整限定名称的类列表
  • --case-update : 使用不匹配的案例重命名文件夹 info|rename
    • info: 仅打印信息,不进行更改
    • rename: 改变文件夹的名称
  • --create-dirs : 通过类命名空间创建缺失的文件夹
  • --create-files : 通过多个类创建缺失的文件
  • --git-clear : 使用clear值将从索引中删除所有缓存的重复文件夹