定制 tareqas/psym 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

tareqas/psym

Composer 安装命令:

composer require tareqas/psym

包简介

A REPL for Symfony and PHP

README 文档

README

A REPL for Symfony and PHP

pSym works both inside and outside Symfony project. When used within a Symfony project, it provides additional features such as access to variables like $kernel, $container, $doctrine, and $em. Additionally, all registered project commands become accessible as well.

The lse command and table(), sql(), and dql() functions are available when Doctrine is installed.

Function html() and features like auto-completion, auto-suggestion, and doc-and-signature work universally.

Installation

To install it, create a project using composer create-project in your preferred location. It supports PHP versions >=7.2 and works with Symfony versions 4, 5, 6, and 7.

# The home directory might be an ideal place to install
cd ~
composer create-project tareqas/psym psym

Next, add the your-psym-installation-path/psym/bin/ directory to your system's PATH, so you can run the psym command directly from your shell.

Warning: Do not install it as a global or local package; it won't work.

Commands

# list all the commands, including your project commands.
list
# or
?

Auto-complete and Auto-suggestion

auto-completion

To get suggestions, press the TAB key.

Note: Sometimes you may need to press SPACE first and then TAB.

# press TAB for suggestion
$kernel->
# it also works with method chaining
$kernel->getBundle()-> 
# press TAB for completion
$kernel->getBund

Documentation and Signature

documentation and signature

You can view PHPDoc documentation and signature for function, property, and method.

# press TAB to display the phpDoc and signature for getBundle
$kernel->getBundle 

lse

lse

The lse command lists all entities managed by Doctrine.

# list of of all matching tables
lse ca
# list all properties, columns, types, and default values of an entity
lse cart
# list of all matching properties for the 'cart' entity
lse cart tot

html()

function html(...$vars): void

The html() function dumps variables and renders them as a browsable HTML page. If any of your variables contain Doctrine objects, it will automatically instantiate all proxy objects.

You can fine-tune the dump by providing additional options in the last parameter as an associative array:

html($var, [
    'nestedLevel' => -1, # or 'level' - how deep it should go to instantiate doctrine proxy object
    'collectionSize' => 1, # or 'size' - cut the Doctrine association collection to this specific size
    'maxString' => -1 # cut the overlong string to this specific size
])
# -1 implies no limit.

table()

function table(string $table, ?string $alias = null): EntityRepository|QueryBuilder|void

The table() function retrieves a repository for a given entity. It returns a Doctrine\ORM\EntityRepository if no alias is provided, or a Doctrine\ORM\QueryBuilder if an alias is specified.

sql()

sql

function sql(string $sql, array $params = []): array|void

The sql() function executes raw SQL queries and returns the result as an associative array. Doctrine is required to use this feature.

# press TAB to display all available tables
sql('select * from '
# press TAB to display all available columns in the 'cart' table
sql('select c. from cart c'

dql()

dql

function dql(string $dql, array $params = []): array|void

The dql() function allows you to execute DQL queries and also returns the result as an associative array.

# press TAB to display all available entities
dql('select * from '
# press TAB to display all available properties in the 'Cart' entity
sql('select c. from App\Entity\Cart c'

Limitation: Auto-completion may have limitations with entity classes due to backslashes (\). Other features work as expected.

And more

To unlock the full potential, explore the PsySH documentation. pSym is built on top of PsySH.

tareqas/psym 适用场景与选型建议

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

它主要适用于以下技术方向: 「symfony」 「console」 「shell」 「interactive」 「REPL」 「psysh」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-18