friendsofhyperf / tinker
The Powerful REPL for Hyperf.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- hyperf/collection: ~3.1.0
- hyperf/command: ~3.1.0
- hyperf/contract: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/framework: ~3.1.0
- hyperf/stringable: ~3.1.0
- hyperf/support: ~3.1.0
- hyperf/tappable: ~3.1.0
- psy/psysh: ^0.10.0 || ^0.11.0 || ^0.12.0
Suggests
- hyperf/view-engine: Suggest for using `Hyperf\ViewEngine\HtmlString`.
- dev-main / 3.1.x-dev
- v3.1.48
- v3.1.41
- v3.1.31.1
- v3.1.31
- v3.1.30
- v3.1.28.2
- v3.1.28
- v3.1.26
- v3.1.23
- v3.1.17
- v3.1.7
- v3.1.1
- v3.1.0
- v3.1.0-rc.22
- v3.1.0-rc.4
- v3.1.0-rc.1
- v3.1.0-beta.20
- v3.1.0-beta.15
- v3.1.0-beta.9
- v3.1.0-beta.6
- v3.1.0-beta.1
- 3.0.x-dev
- v3.0.114
- v3.0.85
- v3.0.80
- v3.0.70
- v3.0.55
- v3.0.52
- v3.0.51
- v3.0.45
- v3.0.44
- v3.0.43
- v3.0.42
- v3.0.40
- v3.0.35
- v3.0.14
- v3.0.6
- v3.0.2
- v3.0.0
- v3.0.0-rc.46
- v3.0.0-rc.30
- v3.0.0-rc.16
- v3.0.0-rc.9
- v3.0.0-rc.8
- v3.0.0-rc.7
- v3.0.0-rc.6
- v3.0.0-rc.4
- v3.0.0-rc.2
- v3.0.0-rc.1
- v3.0.0-beta34
- v3.0.0-beta33
- v3.0.0-beta32
- v3.0.0-beta29
- v3.0.0-beta28
- v3.0.0-beta27
- v3.0.0-beta26
- v3.0.0-beta25
- v3.0.0-beta24
- v3.0.0-beta23
- v3.0.0-beta22
- v3.0.0-beta21
- v3.0.0-beta20
- v3.0.0-beta19
- v3.0.0-beta18
- v3.0.0-beta17
- v3.0.0-beta16
- v3.0.0-beta15
- v3.0.0-beta14
- v3.0.0-beta13
- v3.0.0-beta12
- v3.0.0-beta11
- v3.0.0-beta10
- v3.0.0-beta9
- v3.0.0-beta8
- v3.0.0-beta7
- v3.0.0-beta6
- v3.0.0-beta5
- v3.0.0-beta4
- v3.0.0-beta3
- v3.0.0-beta2
- v3.0.0-beta1
- 2.0.x-dev
- v2.0.28
- v2.0.24
- v2.0.22
- v2.0.19
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-beta3
- v2.0.0-beta2
- v2.0.0-beta1
This package is auto-updated.
Last update: 2024-12-04 02:42:22 UTC
README
The Powerful REPL for Hyperf.
Installation
composer require friendsofhyperf/tinker
Publish Config
php bin/hyperf.php vendor:publish friendsofhyperf/tinker
Usage
php bin/hyperf.php tinker
Commnads
- run command
Psy Shell v0.10.4 (PHP 7.3.11 — cli) >>> $a=1 => 1 >>> $a => 1 >>> define('VERSION', 'v1.0.1') => true >>> VERSION => "v1.0.1" >>>
- The help command
>>> 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 clear-compiled Remove the compiled class file down Put the application into maintenance mode env Display the current framework environment optimize Cache the framework bootstrap files up Bring the application out of maintenance mode migrate Run the database migrations inspire Display an inspiring quote
- get hyperf env
Psy Shell v0.10.4 (PHP 7.2.34 — cli) >>> env("APP_NAME") => "skeleton" >>>
- query db
➜ t.hyperf.com git:(master) ✗ php bin/hyperf.php tinker [DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Config\Listener\RegisterPropertyHandlerListener listener. [DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Paginator\Listener\PageResolverListener listener. [DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener listener. [DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\DbConnection\Listener\RegisterConnectionResolverListener listener. Psy Shell v0.10.4 (PHP 7.2.34 — cli) by Justin Hileman Unable to check for updates >>> $user = App\Model\User::find(1) [DEBUG] Event Hyperf\Database\Model\Events\Booting handled by Hyperf\ModelListener\Listener\ModelHookEventListener listener. [DEBUG] Event Hyperf\Database\Model\Events\Booting handled by Hyperf\ModelListener\Listener\ModelEventListener listener. [DEBUG] Event Hyperf\Database\Model\Events\Booted handled by Hyperf\ModelListener\Listener\ModelHookEventListener listener. [DEBUG] Event Hyperf\Database\Model\Events\Booted handled by Hyperf\ModelListener\Listener\ModelEventListener listener. [DEBUG] Event Hyperf\Database\Events\QueryExecuted handled by App\Listener\DbQueryExecutedListener listener. [DEBUG] Event Hyperf\Database\Model\Events\Retrieved handled by Hyperf\ModelListener\Listener\ModelHookEventListener listener. [DEBUG] Event Hyperf\Database\Model\Events\Retrieved handled by Hyperf\ModelListener\Listener\ModelEventListener listener. => App\Model\User {#81816 +incrementing: true, +exists: true, +wasRecentlyCreated: false, +timestamps: true, } >>> var_dump($user) object(App\Model\User)#81816 (28) { ["table":protected]=> string(5) "users" ["fillable":protected]=> array(2) { [0]=> string(2) "id" [1]=> string(4) "name" } ["casts":protected]=> array(0) { } ["incrementing"]=> bool(true) ["exists"]=> bool(true) ["attributes":protected]=> array(4) { ["id"]=> int(1) ["name"]=> string(5) "arvin" ["created_at"]=> string(19) "2020-11-23 18:38:00" ["updated_at"]=> string(19) "2020-11-23 18:38:03" } ["original":protected]=> array(4) { ["id"]=> int(1) ["name"]=> string(5) "arvin" ["created_at"]=> string(19) "2020-11-23 18:38:00" ["updated_at"]=> string(19) "2020-11-23 18:38:03" } } => null
- show doc
>>> doc md5 function md5($str, $raw_output = unknown) PHP manual not found To document core PHP functionality, download the PHP reference manual: https://github.com/bobthecow/psysh/wiki/PHP-manual >>>
- show class
>>> show App\Model\User 7: /** 8: */ 9: class User extends Model 10: { 11: /** 12: * The table associated with the model. 13: * 14: * @var string 15: */ 16: protected $table = 'users'; 17: /** 18: * The attributes that are mass assignable. 19: * 20: * @var array 21: */ 22: protected $fillable = ['id','name']; 23: /** 24: * The attributes that should be cast to native types. 25: * 26: * @var array 27: */ 28: protected $casts = []; 29: } >>>