Laravel 开发插件必备三件套 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文件中填上:

 

  1. BarryvdhDebugbarServiceProvider::class, 
  2.  
  3. MpociotLaravelTestFactoryHelperTestFactoryHelperServiceProvider::class, 
  4.         
  5. BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class, 

看下开发插件三件套能干些啥,下文中命令可在项目根目录输入php artisan指令列表中查看。

1、barryvdh/laravel-debugbar

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

2、barryvdh/laravel-ide-helper

执行php artisan ide-helper:generate指令前:

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

执行php artisan ide-helper:generate指令后:

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

不仅Facade模式的Route由之前的反白了变为可以定位到源码了,而且输入Config Facade时还方法自动补全auto complete,这个很方便啊。


输入指令php artisan ide-helper:models后,看看各个Model,如Post这个Model:

  1. <?php 
  2.  
  3. namespace App; 
  4.  
  5. use IlluminateDatabaseEloquentModel; 
  6.  
  7. /** 
  8.  * AppPost 
  9.  * 
  10.  * @property integer $id 
  11.  * @property integer $category_id 外键 
  12.  * @property string $title 标题 
  13.  * @property string $slug 锚点 
  14.  * @property string $summary 概要 
  15.  * @property string $content 内容 
  16.  * @property string $origin 文章来源 
  17.  * @property integer $comment_count 评论次数 
  18.  * @property integer $view_count 浏览次数 
  19.  * @property integer $favorite_count 点赞次数 
  20.  * @property boolean $published 文章是否发布 
  21.  * @property CarbonCarbon $created_at 
  22.  * @property CarbonCarbon $updated_at 
  23.  * @property-read AppCategory $category 
  24.  * @property-read IlluminateDatabaseEloquentCollection|AppComment[] $comments 
  25.  * @property-read IlluminateDatabaseEloquentCollection|AppTag[] $tags 
  26.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereId($value) 
  27.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereCategoryId($value) 
  28.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereTitle($value) 
  29.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereSlug($value) 
  30.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereSummary($value) 
  31.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereContent($value) 
  32.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereOrigin($value) 
  33.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereCommentCount($value) 
  34.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereViewCount($value) 
  35.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereFavoriteCount($value) 
  36.  * @method static IlluminateDatabaseQueryBuilder|AppPost wherePublished($value) 
  37.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereCreatedAt($value) 
  38.  * @method static IlluminateDatabaseQueryBuilder|AppPost whereUpdatedAt($value) 
  39.  * @mixin Eloquent 
  40.  */ 
  41. class Post extends Model 
  42.     //Post-Category:Many-One 
  43.     public function category() 
  44.     { 
  45.         return $this->belongsTo(Category::class); 
  46.     } 
  47.  
  48.     //Post-Comment:One-Many 
  49.     public function comments() 
  50.     { 
  51.         return $this->hasMany(Comment::class); 
  52.     } 
  53.  
  54.     //Post-Tag:Many-Many 
  55.     public function tags() 
  56.     { 
  57.         return $this->belongsToMany(Tag::class)->withTimestamps(); 
  58.     } 

根据迁移到库里的表生成字段属性和对应的方法提示,在控制器里输入方法时会自动补全auto complete字段属性的方法:

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

3、mpociot/laravel-test-factory-helper

输入指令php artisan test-factory-helper:generate后,database/factory/ModelFactory.php模型工厂文件会自动生成各个模型对应字段数据。Faker是一个好用的生成假数据的第三方库,而这个开发插件会自动帮你生成这些属性,不用自己写了

转载:https://blog.****.net/h330531987/article/details/79089657

---------------------------------------------------------------------------------------------------------------------------------------

laravel8版本

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

 

其他版本

Laravel 开发插件必备三件套
Laravel 日志管理:按日期切割日志

 转载:https://learnku.com/laravel/wikis/16536