zoukankan      html  css  js  c++  java
  • 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 开发插件必备三件套

    2、barryvdh/laravel-ide-helper

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

    Laravel 开发插件必备三件套

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

    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 开发插件必备三件套

    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版本

     

    其他版本

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

  • 相关阅读:
    CSP-S2-2019游记
    【BZOJ2301】【HAOI2011】Problem B
    【NOIp2017】宝藏
    【NOIp2016】天天爱跑步
    【NOIp2018】保卫王国
    【BZOJ2159】Crash的文明世界
    Van爆零赛总结
    【ZJOI2016】小星星
    【CF1025D】Recovering BST
    【HAOI2016】字符合并
  • 原文地址:https://www.cnblogs.com/yehuisir/p/14810390.html
Copyright © 2011-2022 走看看