一,启动与退出:
liuhongdi@lhdpc:/data/laravel/dignews$ php artisan tinker
Psy Shell v0.11.22 (PHP 8.1.1 — cli) by Justin Hileman
> exit
INFO Goodbye.
二,查询数据
liuhongdi@lhdpc:/data/laravel/dignews$ php artisan tinker
Psy Shell v0.11.22 (PHP 8.1.1 — cli) by Justin Hileman
> $news = new App\Models\News();
= App\Models\News {#6283}
> dump($news->getAll())
三,显示源码
> show $news
8: class News extends Model
9: {
10: use HasFactory;
11:
12: //定义关联的数据表
13: protected $table = 'news';
14:
15: //定义主键
16: protected $primaryKey = 'news_id’;
…
四,查看帮助:
输入help命令即可,如图:
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/10/20/laravel-shi-yong-tinker-10-27/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]
五,查看历史命令
> history
0: app\models\News::getall()
1: $news = new App\Models\News();
2: dump($news->getAll())
六,查看laravel的版本:
liuhongdi@lhdpc:/data/laravel/dignews$ php artisan --version
Laravel Framework 10.27.0
标签:laravel,10.27,liuhongdi,tinker,News,news,com
From: https://www.cnblogs.com/architectforest/p/17780050.html