laravel 笔记

首页 / 正文

官方laravel项目


拉取项目
git clone https://github.com/laravel/laravel.git
切换5.7版本
git checkout 5.7
 

  //根目录安装composer
composer install --ignore-platform-reqs
  //安装第三方模块
composer require houdunwang/laravel-module
  //装依赖
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"

php artisan vendor:publish --provider="Houdunwang\Module\LaravelServiceProvider"

composer.json文件下增加 "Modules\": "Modules"

modules

创建你的第一个模块


php artisan hd:module Admin

Start 此处可略过


//使用composer安装插件,用于实现方便的代码提示功能
composer require barryvdh/laravel-ide-helper

config\app.php文件下的providers添加


Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,

App\Provider\AppServiceProvider.php文件下的register方法添加


   public function register()
    {
            if($this->app->environment() !=='production'){
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
        }
    }

//执行
php artisan ide-helper:generate

phpstorm设置

modules

End

创建登陆注册模块


php artisan make:auth
//创建之后是全英文,可以安装一下语言包
composer require caouecs/laravel-lang:~3.0

app.php 文件下更改


    'locale' => 'zh-CN',
    //项目里面vendor\caouecs\laravel-lang找到zh-CN文件,复制过来resources\lang文件下

resources\lang文件下创建zh-CN.json文件,内容如下

{
    "Login":"登录",
    "Logout":"退出",
    "E-Mail Address":"邮箱",
    "Register":"注册",
    "Password":"密码",
    "Confirm Password":"确认密码",
    "Name":"帐号",
    "Remember Me":"记住我",
    "Forgot Your Password?":"找回密码",
    "Reset Password":"重置密码",
    "Send Password Reset Link":"发送重置密码邮件",
    "Reset Password Notification":"重置密码通知",
    "You are receiving this email because we received a password reset request foryour account":"您收到这封邮件是因为我们收到的帐户码重置请求",
    "If you did not request a password reset, no further action is required.":"如果没有要求重新设置码,则不需要进一步的提作"
}

php artisan make:seeder Userseeder
//创建模型工厂进行数据填充

进入Userseeder.php文件添加


  public function run()
    {
        $user = factory(\App\User::class,30)->create();
        //只执行上面这段就行了,下面代码是我修改第一条数据方便后面测试
        $user = $user[0];
        $user->name = '憨批猪';
        $user->email = '2654743927@qq.com';
        $user->save();
    }

php artisan migrate:fresh --seed //执行
打赏
评论区
头像