Laravel 开发插件必备三件套
先装上开发插件三件套,开发神器。先不管这能干些啥,装上再说。
1、barryvdh/laravel-debugbar
composer require barryvdh/laravel-debugbar --dev
2、barryvdh/laravel-ide-helper
composer require barryvdh/laravel-ide-helper --dev
3、mpociot/laravel-test-factory-helper
composer require mpociot/laravel-test-factory-helper --dev
然后在config/app.php文件中填上:
- Barryvdh\Debugbar\ServiceProvider::class,
- Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider::class,
- Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
看下开发插件三件套能干些啥,下文中命令可在项目根目录输入php artisan指令列表中查看。
1、barryvdh/laravel-debugbar
2、barryvdh/laravel-ide-helper
执行php artisan ide-helper:generate指令前:
执行php artisan ide-helper:generate指令后:
不仅Facade模式的Route由之前的反白了变为可以定位到源码了,而且输入Config Facade时还方法自动补全auto complete,这个很方便啊。
输入指令php artisan ide-helper:models后,看看各个Model,如Post这个Model:
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- /**
- * App\Post
- *
- * @property integer $id
- * @property integer $category_id 外键
- * @property string $title 标题
- * @property string $slug 锚点
- * @property string $summary 概要
- * @property string $content 内容
- * @property string $origin 文章来源
- * @property integer $comment_count 评论次数
- * @property integer $view_count 浏览次数
- * @property integer $favorite_count 点赞次数
- * @property boolean $published 文章是否发布
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * @property-read \App\Category $category
- * @property-read \Illuminate\Database\Eloquent\Collection|\App\Comment[] $comments
- * @property-read \Illuminate\Database\Eloquent\Collection|\App\Tag[] $tags
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereId($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereCategoryId($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereTitle($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereSlug($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereSummary($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereContent($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereOrigin($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereCommentCount($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereViewCount($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereFavoriteCount($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post wherePublished($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereCreatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\App\Post whereUpdatedAt($value)
- * @mixin \Eloquent
- */
- class Post extends Model
- {
- //Post-Category:Many-One
- public function category()
- {
- return $this->belongsTo(Category::class);
- }
- //Post-Comment:One-Many
- public function comments()
- {
- return $this->hasMany(Comment::class);
- }
- //Post-Tag:Many-Many
- public function tags()
- {
- return $this->belongsToMany(Tag::class)->withTimestamps();
- }
- }
根据迁移到库里的表生成字段属性和对应的方法提示,在控制器里输入方法时会自动补全auto complete字段属性的方法:
3、mpociot/laravel-test-factory-helper
输入指令php artisan test-factory-helper:generate后,database/factory/ModelFactory.php模型工厂文件会自动生成各个模型对应字段数据。Faker是一个好用的生成假数据的第三方库,而这个开发插件会自动帮你生成这些属性,不用自己写了
转载:https://blog.csdn.net/h330531987/article/details/79089657
---------------------------------------------------------------------------------------------------------------------------------------
Laravel 日志管理:按日期切割日志
laravel8版本
其他版本