umanit-pomm/cli
Composer 安装命令:
composer require umanit-pomm/cli
包简介
Command line for Pomm.
关键字:
README 文档
README
This is the Cli component for the Pomm database framework.
Configuration
Pomm's Cli is independent from one's development environment, it does not know what configuration types and files are used in the project. To make the Cli work, it is necessary to create a plain PHP bootstrap file that returns a Pomm instance. By default it is named .pomm_cli_bootstrap.php. If the project already has a script that returns a configured Pomm instance, it is possible to specify it to the Cli using the option -b|--bootstrap-file="...".
Database inspection
The inspect command uses the Foundation.Inspector to display information about the database structure.
- pomm:inspect:database - Get schemas in a database.
- pomm:inspect:schema - Get relations information in a schema.
- pomm:inspect:relation - Get information about a relation.
$ ./bin/pomm.php pomm:inspect:schema my_db_config
Found 3 relations in schema 'public'.
+-------------+-------+--------+---------+
| name | type | oid | comment |
+-------------+-------+--------+---------+
| pika | view | 126516 | pika |
| test_unique | table | 127619 | |
| worker | table | 126525 | |
+-------------+-------+--------+---------+
$ ./bin/pomm.php pomm:inspect:relation archived_document my_db_config pylone
Relation pylone.archived_document
+----+-------------+-----------+---------+---------+---------+
| pk | name | type | default | notnull | comment |
+----+-------------+-----------+---------+---------+---------+
| * | document_id | uuid | | yes | |
| | title | varchar | | yes | |
| | archived_at | timestamp | now() | yes | |
| * | version | int4 | | yes | |
| | usable | bool | | no | |
+----+-------------+-----------+---------+---------+---------+
Code generation
The generate commands create PHP class for use of database relations with Pomm's ModelManager package.
- pomm:generate:structure - Generate a RowStructure class according to the relation structure.
- pomm:generate:model - Generate a new configured Model class.
- pomm:generate:entity - Generate an empty FlexibleEntity class.
- pomm:generate:relation-all - Generate the 3 files above for the given relation.
- pomm:generate:schema-all - Generate the 3 files above for every relation in the given schema.
Since you are going to add your own methods in the generated Model and FlexibleEntity classes, they will NOT be overwritten by default by the generate commands. It is somehow possible to do so by implicitly specifying the option --force. All the code in the overwritten classes will then be lost and replaced by a brand new class. Structure files are always overwritten without prior asking for confirmation. To avoid mixing these two kinds of classes, Structure classes are saved under a AutoStructure subdirectory.
Prefixes options
By default, Pomm's ModelManager expects at least the classes to be saved using the following namespaces: DatabaseConfigName\SchemaSchema. It is possible to tell the Cli where this structure starts and how to tune it.
--prefix-dir,-d- indicates where to start the Namespace directory tree.--prefix-ns,-a- indicates an optional namespace prefix.
When no options are specified, generating all relations of public schema will act like the following:
$ ./bin/pomm.php pomm:generate:schema-all -v pomm_test
✓ Creating file './PommTest/PublicSchema/AutoStructure/Pika.php'.
✓ Creating file './PommTest/PublicSchema/PikaModel.php'.
✓ Creating file './PommTest/PublicSchema/Pika.php'.
✓ Creating file './PommTest/PublicSchema/AutoStructure/TestUnique.php'.
✓ Creating file './PommTest/PublicSchema/TestUniqueModel.php'.
✓ Creating file './PommTest/PublicSchema/TestUnique.php'.
✓ Creating file './PommTest/PublicSchema/AutoStructure/Worker.php'.
✓ Creating file './PommTest/PublicSchema/WorkerModel.php'.
✓ Creating file './PommTest/PublicSchema/Worker.php'.
$ tree PommTest
PommTest/
└── PublicSchema
├── AutoStructure
│ ├── Pika.php
│ ├── TestUnique.php
│ └── Worker.php
├── PikaModel.php
├── Pika.php
├── TestUniqueModel.php
├── TestUnique.php
├── WorkerModel.php
└── Worker.php
2 directories, 9 files
It is often not a good idea to have the model's namespace starting at project's root directory. Most of the time, it is put in a Model namespace under sources/lib directory:
$ ./bin/pomm.php pomm:generate:schema-all --prefix-dir sources/lib --prefix-ns Model pomm_test
✓ Creating file 'sources/lib/Model/PommTest/PublicSchema/AutoStructure/Pika.php'.
…
umanit-pomm/cli 适用场景与选型建议
umanit-pomm/cli 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.86k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「cli」 「postgresql」 「pomm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 umanit-pomm/cli 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 umanit-pomm/cli 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 umanit-pomm/cli 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SilverStripe now has tentative support for PostgreSQL ('Postgres')
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
Sql dumps containing databases for the linna apps.
统计信息
- 总下载量: 6.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-13