gokure / hyperf-tinker
Hyperf框架的强大REPL。
v2.1.0
2023-12-13 07:35 UTC
Requires
- php: >=8.0
- hyperf/command: ~3.0.0 || ~3.1.0
- hyperf/contract: ~3.0.0 || ~3.1.0
- hyperf/di: ~3.0.0 || ~3.1.0
- psy/psysh: ^0.10.6 || ^0.11.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- hyperf/database: ~3.0.0 || ~3.1.0
- hyperf/testing: ~3.0.0 || ~3.1.0
- mockery/mockery: ^1.4.2
README
安装
composer require gokure/hyperf-tinker
发布配置
php bin/hyperf.php vendor:publish gokure/hyperf-tinker
使用
php bin/hyperf.php tinker
命令
- 运行命令
>>> $a=1 => 1 >>> $a => 1 >>> define('VERSION', 'v1.0.1') => true >>> VERSION => "v1.0.1" >>>
- 帮助命令
>>> help help Show a list of commands. Type `help [foo]` for information about [foo]. Aliases: ? ls List local, instance or class variables, methods and constants. Aliases: dir dump Dump an object or primitive. doc Read the documentation for an object, class, constant, method or property. Aliases: rtfm, man show Show the code for an object, class, constant, method or property. wtf Show the backtrace of the most recent exception. Aliases: last-exception, wtf? whereami Show where you are in the code. throw-up Throw an exception or error out of the Psy Shell. timeit Profiles with a timer. trace Show the current call stack. buffer Show (or clear) the contents of the code input buffer. Aliases: buf clear Clear the Psy Shell screen. edit Open an external editor. Afterwards, get produced code in input buffer. sudo Evaluate PHP code, bypassing visibility restrictions. history Show the Psy Shell history. Aliases: hist exit End the current session and return to caller. Aliases: quit, q
- 获取hyperf环境
>>> env("APP_NAME") => "skeleton" >>>
- 查询数据库
>>> $user = App\Model\User::find(1) => App\Model\User {#84118 id: 1, name: "Gang Wu", email: "gokure@gmail.com", created_at: "2019-03-12 19:07:08", updated_at: "2021-01-25 10:35:22" }
- 类别名自动加载
>>> $user = User::find(1) [!] Aliasing 'User' to 'App\Model\User' for this Tinker session. => App\Model\User {#84120 id: 1, name: "Gang Wu", email: "gokure@gmail.com", created_at: "2019-03-12 19:07:08", updated_at: "2021-01-25 10:35:22" } >>> collect([1, 2]) => Hyperf\Utils\Collection {#84084 all: [ 1, 2, ], }