🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[laravel5.5中文文档](https://laravelacademy.org/laravel-docs-5_5) - 安装 ~~~ composer create-project laravel/laravel project-name --prefer-dist "5.5.*" composer require barryvdh/laravel-ide-helper --dev composer require barryvdh/laravel-debugbar --dev composer require barryvdh/laravel-cors 解决跨域 composer require laravel/passport 认证 composer require caouecs/laravel-lang:~4.0 中文,需要复制src下中文到语言下 composer require "spatie/laravel-query-builder" api开发必须 composer require encore/laravel-admin composer require tymon/jwt-auth composer require spatie/laravel-permission权限设计 在app/Http/Kernel.php protected $middleware = [ \Barryvdh\Cors\HandleCors::class, ]; 全局跨域 protected $middlewareGroups = [ 'web' => [ ], 'api' => [ \Barryvdh\Cors\HandleCors::class, ], ]; 异常处理404;app/Exceptions/Handler.php 的 render 方法添加如下代码 if ($exception instanceof ModelNotFoundException) { return response()->json([ 'error' => 'Resource not found.' ],404); } ~~~ 常用命令 ~~~ php artisan cache:clear 清理缓存 php artisan make:model Article -m 创建article模型 php artisan migrate 执行迁移文件 php artisan make:seeder ArticlesTableSeeder 生成填充器 php artisan db:seed --class=ArticlesTableSeeder 填充数据 $faker = \Faker\Factory::create('zh_CN'); php artisan make:controller ArticleController 创建控制器 php artisan make:migration --table=users adds_api_token_to_users_table 创建迁移文件AddsApiTokenToUsersTable php artisan make:auth 生成登陆注册认证 php artisan migrate ~~~ redis 支持设置 phpredis和predis ~~~ composer require predis/predis ~~~ - 引用第三方类库 ~~~ 在app下建立Lib目录,然后创建类文件 在composer.js里面添加文件路径 "classmap": [ "database/seeds", "database/factories", "app/Lib" ], "files": ["app/Lib/function.php"], //用于加载函数 执行composer dumpautoload语句 使用某个类 use Mock;然后直接使用即可;没有使用命名空间的可以不用use,直接\Mock::title也是可以的 ~~~