• 首页
  • 前端
    • HTML
    • CSS
    • Javascript
    • XML
    • AJAX
  • 前端框架
    • BootStrap
    • Jquery
  • PHP
    • 语法
    • 核心
    • 面向对象
    • PHP7
    • Socket
    • Swoole
  • 数据库
    • Mysql
    • Redis
    • Memcache
    • MongoDB
  • 优化
    • 优化方案
    • 页面静态化
    • Nginx
  • 后台框架与实战
    • Smarty
    • 源码Blog
    • TP3.2
    • TP3.2商城
    • TP5.0
    • TP5.0商城
    • Laravel
    • Laravel在线教育平台
    • Yii
    • Yii手机直播
    • CodeIgniter
    • Yaf
  • 移动开发
    • 微信公众号
    • 混合APP
  • 二次开发
    • DedeCMS
  • Linux
    • 基本操作
    • 环境搭建
  • 版本控制
    • GIT
    • SVN
  • Node.js
  • 资料库
没有结果
查看所有结果
  • 首页
  • 前端
    • HTML
    • CSS
    • Javascript
    • XML
    • AJAX
  • 前端框架
    • BootStrap
    • Jquery
  • PHP
    • 语法
    • 核心
    • 面向对象
    • PHP7
    • Socket
    • Swoole
  • 数据库
    • Mysql
    • Redis
    • Memcache
    • MongoDB
  • 优化
    • 优化方案
    • 页面静态化
    • Nginx
  • 后台框架与实战
    • Smarty
    • 源码Blog
    • TP3.2
    • TP3.2商城
    • TP5.0
    • TP5.0商城
    • Laravel
    • Laravel在线教育平台
    • Yii
    • Yii手机直播
    • CodeIgniter
    • Yaf
  • 移动开发
    • 微信公众号
    • 混合APP
  • 二次开发
    • DedeCMS
  • Linux
    • 基本操作
    • 环境搭建
  • 版本控制
    • GIT
    • SVN
  • Node.js
  • 资料库
没有结果
查看所有结果
没有结果
查看所有结果

LaravelV8.6.10

Mr.Lee 由 Mr.Lee
2021年12月26日
在 Laravel
0
laravel

laravel

0
分享
81
浏览

Mac下搭建Laravel环境(V8.6.10)

Demo

1.需要的安装文件 Mamp Pro & Phpstrom

MAMP Pro 6.6 fix – 快速安装PHP/MySQL开发环境

PhpStorm 2021.3

SourceTree 4.1.5

Navicat Premium 15.0.30

Another Redis Desktop Manager 1.5.0 

2.安装Laravel

Mac下安装Laravel

3.配置开发环境

MAMP搭建Laravel虚拟机环境

4.伪静态

laravel+Apache 解决路由404问题

.htaccess

<IfModule mod_rewrite.c>  
    <IfModule mod_negotiation.c>  
        Options +FollowSymLinks  
    </IfModule>  
  
    RewriteEngine On  
  
    # Redirect Trailing Slashes If Not A Folder...  
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteRule ^(.*)/$ /$1 [L,R=301]  
  
    # Handle Front Controller...  
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteRule ^ index.php [L]  
  
    # Handle Authorization Header  
    RewriteCond %{HTTP:Authorization} .  
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]  
</IfModule>  

5.laravel-modules安装

Larvel-modules会在项目目录下生成modules目录,不会更改框架原有结构,方便后续框架升级,开发代码直接写在modules目录下。

5.1.首先在 Laravel 项目根目录下使用 Composer 安装该扩展包。


composer require nwidart/laravel-modules


5.2.你可以通过运行如下命令来发布配置文件。


php artisan vendor:publish –provider=”Nwidart\Modules\LaravelModulesServiceProvider”

5.3.通过如下命令生成应用的第一个模块。


php artisan module:make Admin


5.4.要让模块目录中定义的类可以自动加载,需要配置根目录下的composer.json。

{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/"
    }
  }
}

5.5.配置完成后运行以下命令让修改生效。


composer dump-autoload

5.6.执行域名加模块名(例如:http://demo:8888/admin)

6.laravel8自动生成api文档

laravel8自动生成api文档

Swagger 使用教程

Swagger生成api接口文档

添加配置:

路径:resources/views/vendor/l5-swagger/index.blade.php

添加:deepLinking: true

修改默认模块

路径:config/l5-swagger.php

将 base_path(‘app’), 更改为 base_path(‘Modules’),

php artisan l5-swagger:generate

最终效果:

7.laravel数据迁移加注释

默认laravel是没有带添加表注释组件的,这里需要安装zedisdog/laravel-schema-extend包
该组件包要求使用大于等于5.0版本的laravel

1.拉取组件

composer require zedisdog/laravel-schema-extend

2.申明依赖 (修改config->app.php->aliases)

'aliases' => [
    ...
    // 'Schema' => Illuminate\Support\Facades\Schema::class,
    'Schema'    => Jialeo\LaravelSchemaExtend\Schema::class,

],

3.使用(默认创建的migration文件对应的“Schema”还是引用的laravel自带的,需要修改为该组件包的引用)

 //use Illuminate\\Support\\Facades\\Schema;
 use Jialeo\\LaravelSchemaExtend\\Schema;
Schema::create('users', function (Blueprint $table) {
$table->comment = '用户表';
 });

8.JWT用户验证

1.安装 jwt-auth。
composer require tymon/jwt-auth 1.*@rc
或者
composer require tymon/jwt-auth:^1.0.2

2.将服务提供程序添加到配置文件中的providers数组,config/app.php如下所示:
'providers' => [
        ...
        Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
    ]

3.运行以下命令以发布程序包配置文件:
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

4.生成加密密钥:
php artisan jwt:secret

5.修改 config/auth.php
'guards'  =>  [
        'auth_admin' => [
            'driver' => 'jwt',
            'provider' => 'auth_admins'
        ]
    ],
'providers' => [
        'auth_admins' => [
            'driver' => 'eloquent',
            'model' => Modules\Admin\Models\AuthAdmin::class,
        ]
    ],
6.创建模型
<?php
namespace Modules\Admin\Models;
use DateTimeInterface;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class AuthAdmin extends Authenticatable implements JWTSubject
{
    use Notifiable;
    protected $guard = 'auth_admin';
    protected $hidden = [
        'password'
    ];
    /**
     * @name jwt标识
     * @description
     * @author Winston
     * @date 2021/12/25 3:11
     **/
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }
    /**
     * @name jwt自定义声明
     * @description
     * @author Winston
     * @date 2021/12/25 3:11
     **/
    public function getJWTCustomClaims()
    {
        return [];
    }
    /**
     * @name 更新时间为null时返回
     * @description
     * @author Winston
     * @date 2021/12/25 3:11
     **/
    public function getUpdatedAtAttribute($value)
    {
        return $value?$value:'';
    }
    /**
     * @name  关联权限组表   多对一
     * @description
     * @author Winston
     * @date 2021/12/25 3:12
     **/
    public function auth_groups()
    {
        return $this->belongsTo('Modules\Admin\Models\AuthGroup','group_id','id');
    }
    /**
     * @name  关联平台项目表   多对一
     * @description
     * @author Winston
     * @date 2021/12/25 3:12
     **/
    public function auth_projects()
    {
        return $this->belongsTo('Modules\Admin\Models\AuthProject','project_id','id');
    }
    /**
     * @name 时间格式传唤
     * @description
     * @author Winston
     * @date 2021/12/25 16:15
     **/
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
}
7.创建token的Services
<?php
/**
 * @Name 管理员信息服务
 * @Description
 * @Auther Winston
 * @Date 2021/12/25 17:10
 */
namespace Modules\Admin\Services\auth;
use Modules\Admin\Services\BaseApiService;
use Modules\Common\Exceptions\ApiException;
use Modules\Common\Exceptions\MessageData;
use Modules\Common\Exceptions\StatusData;
use Tymon\JWTAuth\Exceptions\TokenBlacklistedException;
use Tymon\JWTAuth\Facades\JWTAuth;

class TokenService extends BaseApiService
{
    /**
     * @name 设置token 生成机制
     * @description
     * @author Winston
     * @date 2021/12/25 17:23
     * @return JSON
     **/
    public function __construct()
    {
        \Config::set('auth.defaults.guard', 'auth_admin');
        \Config::set('jwt.ttl', 60);
    }
    /**
     * @name 设置token
     * @description
     * @author Winston
     * @date 2021/12/25 17:24
     * @param data  Array 用户信息
     * @param data.username String 账号
     * @param data.password String 密码$
     * @return JSON | Array
     **/
    public function setToken($data){
        if (! $token = JWTAuth::attempt($data)){
            $this->apiError('token生成失败');
        }
        return $this->respondWithToken($token);
    }
    /**
     * @name 刷新token
     * @description
     * @author Winston
     * @date 2021/12/25 17:48
     * @return JSON
     **/
    public function refreshToken()
    {
        try {
            $old_token = JWTAuth::getToken();
            $token = JWTAuth::refresh($old_token);
        }catch (TokenBlacklistedException $e) {
            // 这个时候是老的token被拉到黑名单了
            throw new ApiException(['status'=>StatusData::TOKEN_ERROR_BLACK,'message'=>MessageData::TOKEN_ERROR_BLACK]);
        }
        return $this->apiSuccess('', $this->respondWithToken($token));
    }
    /**
     * @name 管理员信息
     * @description
     * @author Winston
     * @date 2021/12/25 19:11
     * @return Array
     **/
    public function my():Object
    {
        return JWTAuth::parseToken()->touser();
    }
    /**
     * @name
     * @description
     * @author Winston
     * @date 2021/12/25 9:53
     * @method  GET
     * @param
     * @return JSON
     **/
    public function info()
    {
        $data = $this->my();
        return $this->apiSuccess('',['username'=>$data['username']]);
    }
    /**
     * @name 退出登录
     * @description
     * @author Winston
     * @date 2021/12/25 19:12
     * @return JSON
     **/
    public function logout()
    {
        JWTAuth::parseToken()->invalidate();
        return $this->apiSuccess('退出成功!');
    }

    /**
     * @name 组合token数据
     * @description
     * @author Winston
     * @date 2021/12/25 17:47
     * @return Array
     **/
    protected function respondWithToken($token):Array
    {
        return [
            'token' => $token,
            'token_type' => 'bearer',
            'expires_in' => JWTAuth::factory()->getTTL() * 60
        ];
    }
}
8.创建登录Services
<?php
/**
 * @Name 用户登录服务
 * @Description
 * @Auther Winston
 * @Date 2021/12/25 16:50
 */
namespace Modules\Admin\Services\auth;
use Modules\Admin\Services\BaseApiService;
use Modules\Admin\Models\AuthAdmin as AuthAdminModel;
class LoginService extends BaseApiService
{
    /**
     * @name 用户登录
     * @description
     * @author Winston
     * @date 2021/12/25 16:53
     * @param data  Array 用户信息
     * @param data.username String 账号
     * @param data.password String 密码
     * @return JSON
     **/
    public function login(array $data){
        if (true == \Auth::guard('auth_admin')->attempt($data)) {
            $userInfo = AuthAdminModel::where(['username'=>$data['username']])->select('id','username')->first();
            if($userInfo){
                $user_info = $userInfo->toArray();
                $user_info['password'] = $data['password'];
                $token = (new TokenService())->setToken($user_info);
                return $this->apiSuccess('登录成功!',$token);
            }
        }
        $this->apiError('账号或密码错误!');
    }
}
9.创建中间件
<?php
// +----------------------------------------------------------------------
// | Name: 管理系统 [ 为了快速搭建软件应用而生的,希望能够帮助到大家提高开发效率。 ]
// +----------------------------------------------------------------------
// | Copyright: (c) 2020~2021 http://liyouran.asia/ All rights reserved.
// +----------------------------------------------------------------------
// | Licensed: 这是一个自由软件,允许对程序代码进行修改,但希望您留下原有的注释。
// +----------------------------------------------------------------------
// | Author: Winston <liyouran@live.com>
// +----------------------------------------------------------------------
// | Version: V1
// +----------------------------------------------------------------------

/**
 * @Name  后台权限验证中间件
 * @Description
 * @Auther Winston
 * @Date 2021/12/25 13:37
 */

namespace Modules\Admin\Http\Middleware;

use Closure;
use Modules\Admin\Services\log\OperationLogService;
use Modules\Common\Exceptions\ApiException;
use Illuminate\Http\Request;
use Modules\Common\Exceptions\MessageData;
use Modules\Common\Exceptions\StatusData;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
use Tymon\JWTAuth\Exceptions\TokenBlacklistedException;
use JWTAuth;
use Modules\Admin\Models\Admin as AdminModel;
use Modules\Admin\Models\AuthGroup as AuthGroupModel;
use Modules\Admin\Models\AuthRule as AuthRuleModel;
class AdminApiAuth
{

    public function handle($request, Closure $next)
    {
        \Config::set('auth.defaults.guard', 'auth_admin');
        \Config::set('jwt.ttl', 60);
        $route_data = $request->route();
        $url = str_replace($route_data->getAction()['prefix'] . '/',"",$route_data->uri);
        $url_arr = ['auth/login/login','auth/index/getMain','auth/index/refreshToken'];
        $api_key = $request->header('apikey');
        if($api_key != config('admin.api_key')){
            throw new ApiException(['status'=>StatusData::TOKEN_ERROR_KEY,'message'=>MessageData::TOKEN_ERROR_KEY]);
            return $next();
        }
        if(in_array($url,$url_arr)){
            return $next($request);
        }
        try {
            if (! $user = JWTAuth::parseToken()->authenticate()) {  //获取到用户数据,并赋值给$user   'msg' => '用户不存在'
                throw new ApiException(['status'=>StatusData::TOKEN_ERROR_SET,'message'=>MessageData::TOKEN_ERROR_SET]);
                return $next();
            }

        }catch (TokenBlacklistedException $e) {
            //token无效
            if(in_array($url,['auth/index/logout'])){
                return $next($request);
            }
            // 这个时候是老的token被拉到黑名单了
            throw new ApiException(['status'=>StatusData::TOKEN_ERROR_BLACK,'message'=>MessageData::TOKEN_ERROR_BLACK]);
            return $next();
        } catch (TokenExpiredException $e) {
            //token无效
            if(in_array($url,['auth/index/logout'])){
                return $next($request);
            }
            //token已过期
            throw new ApiException(['status'=>StatusData::TOKEN_ERROR_EXPIRED,'message'=>MessageData::TOKEN_ERROR_EXPIRED]);
            return $next();
        } catch (TokenInvalidException $e) {
            //token无效
            if(!in_array($url,['auth/index/refresh','auth/index/logout'])){
                throw new ApiException(['status'=>StatusData::TOKEN_ERROR_JWT,'message'=>MessageData::TOKEN_ERROR_JWT]);
            }
            return $next();
        } catch (JWTException $e) {
            //'缺少token'
            throw new ApiException(['status'=>StatusData::TOKEN_ERROR_JTB,'message'=>MessageData::TOKEN_ERROR_JTB]);
            return $next();
        }
        // 写入日志
        (new OperationLogService())->store($user['id']);
//        if(!in_array($url,['auth/index/refresh','auth/index/logout'])){
//            if($user['id'] != 1 && $id = AuthRuleModel::where(['href'=>$url])->value('id')){
//                $rules = AuthGroupModel::where(['id'=>$user['group_id']])->value('rules');
//                if(!in_array($id,explode('|',$rules))){
//                    throw new ApiException(['code'=>6781,'msg'=>'您没有权限!']);
//                }
//            }
//        }
        return $next($request);
    }
}
10.laravel登陆模块Demo

10.1.修改config/auth.php
增加guards、providers

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
        'auth_admin' => [
            'driver' => 'jwt',
            'provider' => 'auth_admins'
        ]
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],
        'auth_admins' => [
            'driver' => 'eloquent',
            'model' => Modules\Admin\Models\AuthAdmin::class,
        ]
    ],

10.2.增加中间件
\Modules\Admin\Http\Middleware\AdminApiAuth

10.3.app\Http\Kernel.php $routeMiddleware中增加中间件
'AdminApiAuth'=> \Modules\Admin\Http\Middleware\AdminApiAuth::class,

10.4.Modules\Admin\Config\config.php 定义api_key

return [
'name' => 'Admin',
'api_key'=>'123456',
'update_pwd'=>'123456',
];

10.5编写基础控制器
<?php
// +----------------------------------------------------------------------
// | Name: 管理系统 [ 为了快速搭建软件应用而生的,希望能够帮助到大家提高开发效率。 ]
// +----------------------------------------------------------------------
// | Copyright: (c) 2021~2022 http://liyouran.asia All rights reserved.
// +----------------------------------------------------------------------
// | Licensed: 这是一个自由软件,允许对程序代码进行修改,但希望您留下原有的注释。
// +----------------------------------------------------------------------
// | Author: Winston <liyouran@live.com>
// +----------------------------------------------------------------------
// | Version: V1
// +----------------------------------------------------------------------

/**
 * @Name 当前模块控制器基类
 * @Description
 * @Auther Winston
 * @Date 2021/12/26 13:10
 */

namespace Modules\Admin\Http\Controllers\v1;


use Modules\Common\Controllers\BaseController;

class BaseApiController extends BaseController
{
    public function __construct(){
        parent::__construct();
    }
}


10.6.编写登陆controller
<?php
// +----------------------------------------------------------------------
// | Name: 管理系统 [ 为了快速搭建软件应用而生的,希望能够帮助到大家提高开发效率。 ]
// +----------------------------------------------------------------------
// | Copyright: (c) 2021~2022 http://liyouran.asia All rights reserved.
// +----------------------------------------------------------------------
// | Licensed: 这是一个自由软件,允许对程序代码进行修改,但希望您留下原有的注释。
// +----------------------------------------------------------------------
// | Author: Winston <liyouran@live.com>
// +----------------------------------------------------------------------
// | Version: V1
// +----------------------------------------------------------------------

/**
 * @Name 用户登录
 * @Description
 * @Auther Winston
 * @Date 2021/12/26 13:10
 */

namespace Modules\Admin\Http\Controllers\v1;


use Modules\Admin\Http\Requests\LoginRequest;
use Modules\Admin\Services\auth\LoginService;
class LoginController extends BaseApiController
{
    /**
     * @name 用户登录
     * @description
     * @author Winston
     * @date 2021/12/26 13:10
     * @method  POST
     * @param username String 账号
     * @param password String 密码
     * @return JSON
     **/
    public function login(LoginRequest $request)
    {
        return (new LoginService())->login($request->only(['username','password']));
    }
}

10.7.编写登陆request
<?php

namespace Modules\Admin\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LoginRequest extends FormRequest
{
	/**
     * php artisan module:make-request LoginRequest AuthAdmin
     */


	 /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
			'username' => 'required',
            'password'  => 'required'
        ];
    }
	public function messages(){
		return [
			'username.required' => '请输入账号!',
			'password.required' => '请输入密码!',
		];
	}

}


10.8.编写api路由
<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/admin', function (Request $request) {
    return $request->user();
});

Route::group(["prefix"=>"v1/admin","middleware"=>"AdminApiAuth"],function (){
    //登录
    Route::post('login/login', 'v1\LoginController@login');
});


10.9.修改config/databases.php
增加表前缀:prefix => 'lv_',

10.10.修改.env中数据库连接配置
DB_PORT:8889,
DB_DATABASES:laravel,
DB_USERNAME=root,
DB_PASSWORD=root,

10.11.连接数据库,创建用户表及数据初始化
USE laravel;
DROP TABLE IF EXISTS `lv_auth_admins`;
CREATE TABLE `lv_auth_admins` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员ID',
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
`phone` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '手机号',
`username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '账号',
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密码',
`group_id` int(11) DEFAULT NULL COMMENT '权限组ID',
`project_id` int(11) DEFAULT NULL COMMENT '项目ID',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态:0=禁用,1=启用',
`created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `lv_auth_admins_username_unique` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员表';

INSERT INTO `lv_auth_admins` VALUES (1,'','','admin','$2y$10$gddj.QV7l7OP3I2MpgM9COcCKCBM8SMPq.xe/JrqkOXY3DlnozTP.',1,1,1,'2021-12-26 14:56:02','2021-12-26 14:56:02');
INSERT INTO `lv_auth_admins` VALUES (2,'winston','','winston','$2y$10$NhdagpIFbxK2zAVFeCFEa.wUrtKv.2o4aG4ZZ5W3yYB9epkx/Xm9y',2,1,1,'2021-12-26 14:56:02','2021-12-26 14:56:02');

10.12.php artisan l5-swagger:generate更新接口文档

10.13.打开http://域名/api/documentation 查看文档及进行测试

9.laravel使用redis

首先确认服务器已经安装redis服务,php安装了redis扩展.
因为我们在laravel的项目中需要下载laravel的redis扩展

composer require predis/predis

1.打开config/database.php。在redis配置项中增加session的连接
'session' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 10,
 ],
2.打开config/session.php ,修改driver配置项,将默认的’file’改为’redis’;connection配置项填入第一步中配置的redis连接名’session’
'driver' => env('SESSION_DRIVER','redis'),
'connection' => 'session',
3.修改.env文件,使用redis存取sessoin
SESSION_DRIVER=redis

phpstorm相关配置

1.phpstorm设置ctrl+鼠标滚轮更改字体大小。

Flie->Settings->Editor->General

Flie->Settings->File Encodings

File->setting–>Editor–>File and Code Templates

// +----------------------------------------------------------------------
// | Name: 管理系统 [ 为了快速搭建软件应用而生的,希望能够帮助到大家提高开发效率。 ]
// +----------------------------------------------------------------------
// | Copyright: (c) 2020~2021 http://liyouran.asia/ All rights reserved.
// +----------------------------------------------------------------------
// | Licensed: 这是一个自由软件,允许对程序代码进行修改,但希望您留下原有的注释。
// +----------------------------------------------------------------------
// | Author: Winston <liyouran@live.com>
// +----------------------------------------------------------------------
// | Version: V1
// +----------------------------------------------------------------------

/**
 * @Name   
 * @Description
 * @Auther Winston
 * @Date ${DATE} ${HOUR}:${MINUTE}
 */

4.设置方法注释。

File->setting-->Editor-->live Templates
点击右边加号添加一个Templates Group -> 然后选中添加的Group再次点击加号添加Live Templates,之后点击Edit variables,配置variables。
/**
 * @Name 
 * @Author Winston
 * @Description 
 * @Date $date$ $time$ 
 * @Method  GET	
 * @Param 
 * @Return JSON
 **/

NUXT文档

nuxt安装

确保安装了 npx(npx 在 NPM 版本 5.2.0 默认安装了):

npx create-nuxt-app <项目名>
或者用 yarn :

yarn create nuxt-app <项目名>
它会让你进行一些选择:

在集成的服务器端框架之间进行选择:
None (Nuxt 默认服务器)
Express
Koa
Hapi
Feathers
Micro
Fastify
Adonis(WIP)
选择您喜欢的 UI 框架:
None (无)
Bootstrap
Vuetify
Bulma
Tailwind
Element UI
Ant Design Vue
Buefy
iView
Tachyons
选择您喜欢的测试框架:
None (随意添加一个)
Jest
AVA
选择你想要的 Nuxt 模式 (UniversalorSPA)
添加axios module以轻松地将 HTTP 请求发送到您的应用程序中。
添加EsLint以在保存时代码规范和错误检查您的代码。
添加Prettier以在保存时格式化/美化您的代码。
当运行完时,它将安装所有依赖项,因此下一步是启动项目:

$ cd
$ npm run dev

应用现在运行在 http://localhost:3000 上运行。

注意:Nuxt.js 会监听pages目录中的文件更改,因此在添加新页面时无需重新启动应用程序。

了解模板项目的目录结构:目录结构。

从头开始新建项目
如果不使用 Nuxt.js 提供的 starter 模板,我们也可以从头开始新建一个 Nuxt.js 应用项目,过程非常简单,只需要1 个文件和 1 个目录。如下所示:

$ mkdir <项目名>
$ cd <项目名>

提示:将<项目名>替换成为你想创建的实际项目名。

新建 package.json 文件
package.json文件用来设定如何运行nuxt:

{
“name”: “my-app”,
“scripts”: {
“dev”: “nuxt”
}
}

上面的配置使得我们可以通过运行npm run dev来运行nuxt。

安装nuxt
一旦package.json创建好, 可以通过以下 npm 命令将nuxt安装至项目中:

npm install –save nuxt

pages 目录
Nuxt.js 会依据pages目录中的所有*.vue文件生成应用的路由配置。

创建pages目录:

mkdir pages

创建我们的第一个页面pages/index.vue:


然后启动项目:

$ npm run dev

nuxt的生命周期

服务端生命周期
服务器初始化nuxtServerInit
创建store/index.js

export const actions = {
nuxtServerInit(store,context){
console.log(‘nuxtServerInit’,store,context)
}
}
中间件运行middleware
在nuxt.config.js中定义中间件

router:{
middleware:’auth’
}
创建中间件文件middleware/auth.js

export default function({store,route,redirect,params,query,req,res}) {
console.log(‘middleware’)
}
定义在layouts/default.vue中

export default{
// middleware:’auth’ ,
middleware(){
console.log(‘middleware’)
}
}
定义在pages/index.vue中

export default{
// middleware:’auth’ ,
middleware(){
console.log(‘middleware’)
}
}
验证参数validate

export default{
validate(context){
console.log(‘validate’)
return true
}
}
异步数据处理asyncData、 fetch

export default{
asyncData(context){
console.log(‘asyncData’)
return {
a:666
}
},
fetch(context){
console.log(‘fetch’)
}
}
开始客户端渲染Render

Vue生命周期 SSR CSR
组件创建前beforeCreated

export default{
beforeCreated(){
console.log(‘beforeCreated’)
}
}
组件创建后created

export default{
created(){
console.log(‘created’)
}
}
运行在客户端
组件加载前 beforeMount
组件加载完毕 mounted
组件更新前 beforeUpdate
组件更新完毕 updated
组件卸载前 beforeDestroy
组件卸载后 destroyed

nuxt安装element-ui

1.安装element-ui
npm install element-ui –save –registry=https://registry.npm.taobao.org
2.创建文件
在项目的根目录下的plugins下创建element-ui.js文件

import Vue from “vue”;
import ElementUI from “element-ui”
Vue.use(ElementUI)

import Button from “element-ui”
Vue.use(Button)
3.引入文件
在nuxt.config.js中修改如下:

// Global CSS: https://go.nuxtjs.dev/config-css
css: [ “element-ui/lib/theme-chalk/index.css”],

// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [{ src: “~plugins/element-ui”,ssr:true,mode:’server’//client }],
build:{
transpile:[‘/^element-ui/’]
}

vue监听路由

watch:{
$route:{
immediate:true,
handler(route){

      }
}

}

vue跳转页面

this.$router.push()

Nuxt安装scss(sass)

1.安装需要用到的loader

npm install --save-dev node-sass@4.12.0 --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
npm install --save-dev sass-loader@7.1.0  --registry=https://registry.npm.taobao.org

2.使用

<style lang="scss">//注意!这里很关键,很多配置成了不编译就是漏了lang="scss"

   @import '../assets/css/index.scss';
   @import '../assets/css/base.scss';
   @import '../assets/css/common.scss';

</style>

nuxt数据交互

1.nuxt做数据交互需要依靠 @nuxtjs/axios@nuxtjs/proxy

npm install @nuxtjs/axios  --save --registry=https://registry.npm.taobao.org
npm install @nuxtjs/proxy --save --registry=https://registry.npm.taobao.org

2.在nuxt.config.js中进行配置

modules:[
    '@nuxtjs/axios'
]

3.使用axios

async asyncData({$axios}){
    const res = await $axios({url:'接口'})
}

4.处理跨域请求, 在nuxt.config.js中进行配置

        axios:{
                proxy:true,//  开启跨域行为
                prefix:'/api/v1/blogApi',  //配置基本的url地址 
          },
        
        proxy:{
                '/api':{
                target:'http://www.mileduo.com',  //  代理转发的地址
                pathRewrite:{
                // '^/api':''                // 找到地址中的api并替换成空    
                       }
                }
        
          },

5.定义拦截器,修改nuxt.config.js

plugins:[
    {
        src:'~/plugins/axios',
        'ssr':true     //  服务端渲染
    }
]

6.书写axios.js

export default function({$axios,redirect,route,store}){
    // 基本配置
    $axios.defaults.timeout = 1000
    $axios.defaults.validateStatus = (status)=>{
            return status >= 200 && status < 600
    }
    // 请求拦截
    $axios.onRequest(config=>{
        config.headers.token = ''
        return config
    })
    // 相应拦截
    $axios.onResponse(res\=>{
        returnres.data
    })
    // 错误处理
    $axios.onError(error\=>{
        return error
    })
}

7.Promise返回值

return new Promise(resolve=>{

    resolve(res.data)

})


nuxt中使用vuex

1.定义

export const state = ()=>({
    typeList : []
})
export const mutations = {
    SET_TYPE_LIST(state,typeList){
        state.typeList = typeList
    }
 }
export const actions = {
     UPDATE_TYPE_LIST({commit,state},typeList){
            commit('SET_TYPE_LIST',typeList)        
    }
}
export const getters = {
    getTypeList(state){
        return state.typeList
    }
}

2.使用

// 调用actions   异步请求
this.$store.dispatch('UPDATE_TYPE_LIST',[])

// 调用mutations 
this.$store.commit('SET_TYPE_LIST',[])

辅助函数

 import {mapActions,mapGetters,mapState,mapMutations} from 'vuex'

methods:{
        getTypeList(){
            this.UPDATE_TYPE_LIST([])
            this.SET_TYPE_LIST([])
        },
    ...mapActions('user',['UPDATE_TYPE_LIST'])
    ...mapMutations('user',['SET_TYPE_LIST'])
},
// 计算属性
computed:{
    ..mapGetters('模块名称,根模块可以不传',['getTypeList'])
     ..mapState('模块名称,根模块可以不传',['typeList '])
}

nuxt的token持久化存储

1.安装cookie-nuiversal-nuxt

npm install cookie-nuiversal-nuxt --save  --registry=https://registry.npm.taobao.org

2.配置nuxt.config.js

modules:[
    'cookie-nuiversal-nuxt'
]

.3.使用

this.$cookies.set('user',[])
this.$cookies.get('user')
this.$cookies.remove('user')

4.登录跳转

if(!this.$route.query.path || /login/reg/.test(this.$route.query.path)){
    this.$router.replace('/user')
}else{
    this.$router.replace(this.$route.query.path)
}

5.页面刷新初始化vuex

export const actions = {
    nuxtServerInit(store,{app:{$cookies}}){
        let user = $cookies.get('user')
        user = user?user:''
        store.commit('user/asdds')
    }
}

6.拦截器定义

$axios.onRequest(config=>{
    config.headers.token = store.state.user.token 
})

nuxt定义错误页面

在layouts下创建error.vue页面,内容如下。

<template>
    <div>
        <h1 v-if="error.statusCode">{{error.message}}</h1>
        <h1 v-else>应用异常</h1>
        <el-button @click="$router.replace('/')">返回首页</el-button>
    </div>
</template>
<script>
    export default{
        props:['error']
    }
</script>

unxt路由跳转过度动画

1.在/assert目录下建立一个page-transletion.css文件,里面包含过渡动画内容,内容如下:

 .page-enter-active, .page-leave-active {
  transition: opacity  .5s;
  }
  .page-enter, .page-leave-active {
  opacity: 0;
  }

2.在nuxt.config.js中配置:

css: [
'assets/page-transletion.css'
]

nuxt自定义loading

1.修改配置

loading:{color:#399,height:'3px'}
loading:'~/components/Loading/index.vue'

2.编写loading组件

<template lang="html">
  <div class="loading-page" v-if="loading">
    <p>Loading...</p>
  </div>
</template>

<script>
export default {
  data: () => ({
    loading: false
  }),
  methods: {
    start () {
      this.loading = true
    },
    finish () {
      this.loading = false
    }
  }
}
</script>

<style scoped>
.loading-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
  padding-top: 200px;
  font-size: 30px;
  font-family: sans-serif;
}
</style>

ZSH

Last login: Sat Dec 25 13:15:03 on console
lee@MacBook-Pro ~ % composer create-project --prefer-dist laravel/laravel laraveldemo
Creating a "laravel/laravel" project at "./laraveldemo"
Installing laravel/laravel (v8.6.10)
  - Installing laravel/laravel (v8.6.10): Extracting archive
Created project in /Users/lee/laraveldemo
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 110 installs, 0 updates, 0 removals
  - Locking asm89/stack-cors (v2.0.3)
  - Locking brick/math (0.9.3)
  - Locking dflydev/dot-access-data (v3.0.1)
  - Locking doctrine/inflector (2.0.4)
  - Locking doctrine/instantiator (1.4.0)
  - Locking doctrine/lexer (1.2.1)
  - Locking dragonmantank/cron-expression (v3.1.0)
  - Locking egulias/email-validator (2.1.25)
  - Locking facade/flare-client-php (1.9.1)
  - Locking facade/ignition (2.17.3)
  - Locking facade/ignition-contracts (1.0.2)
  - Locking fakerphp/faker (v1.17.0)
  - Locking filp/whoops (2.14.4)
  - Locking fruitcake/laravel-cors (v2.0.4)
  - Locking graham-campbell/result-type (v1.0.4)
  - Locking guzzlehttp/guzzle (7.4.1)
  - Locking guzzlehttp/promises (1.5.1)
  - Locking guzzlehttp/psr7 (2.1.0)
  - Locking hamcrest/hamcrest-php (v2.0.1)
  - Locking laravel/framework (v8.77.1)
  - Locking laravel/sail (v1.12.12)
  - Locking laravel/sanctum (v2.13.0)
  - Locking laravel/serializable-closure (v1.0.5)
  - Locking laravel/tinker (v2.6.3)
  - Locking league/commonmark (2.1.0)
  - Locking league/config (v1.1.1)
  - Locking league/flysystem (1.1.9)
  - Locking league/mime-type-detection (1.9.0)
  - Locking mockery/mockery (1.4.4)
  - Locking monolog/monolog (2.3.5)
  - Locking myclabs/deep-copy (1.10.2)
  - Locking nesbot/carbon (2.55.2)
  - Locking nette/schema (v1.2.2)
  - Locking nette/utils (v3.2.6)
  - Locking nikic/php-parser (v4.13.2)
  - Locking nunomaduro/collision (v5.10.0)
  - Locking opis/closure (3.6.2)
  - Locking phar-io/manifest (2.0.3)
  - Locking phar-io/version (3.1.0)
  - Locking phpdocumentor/reflection-common (2.2.0)
  - Locking phpdocumentor/reflection-docblock (5.3.0)
  - Locking phpdocumentor/type-resolver (1.5.1)
  - Locking phpoption/phpoption (1.8.1)
  - Locking phpspec/prophecy (v1.15.0)
  - Locking phpunit/php-code-coverage (9.2.10)
  - Locking phpunit/php-file-iterator (3.0.6)
  - Locking phpunit/php-invoker (3.1.1)
  - Locking phpunit/php-text-template (2.0.4)
  - Locking phpunit/php-timer (5.0.3)
  - Locking phpunit/phpunit (9.5.10)
  - Locking psr/container (1.1.2)
  - Locking psr/event-dispatcher (1.0.0)
  - Locking psr/http-client (1.0.1)
  - Locking psr/http-factory (1.0.1)
  - Locking psr/http-message (1.0.1)
  - Locking psr/log (2.0.0)
  - Locking psr/simple-cache (1.0.1)
  - Locking psy/psysh (v0.10.12)
  - Locking ralouphie/getallheaders (3.0.3)
  - Locking ramsey/collection (1.2.2)
  - Locking ramsey/uuid (4.2.3)
  - Locking sebastian/cli-parser (1.0.1)
  - Locking sebastian/code-unit (1.0.8)
  - Locking sebastian/code-unit-reverse-lookup (2.0.3)
  - Locking sebastian/comparator (4.0.6)
  - Locking sebastian/complexity (2.0.2)
  - Locking sebastian/diff (4.0.4)
  - Locking sebastian/environment (5.1.3)
  - Locking sebastian/exporter (4.0.4)
  - Locking sebastian/global-state (5.0.3)
  - Locking sebastian/lines-of-code (1.0.3)
  - Locking sebastian/object-enumerator (4.0.4)
  - Locking sebastian/object-reflector (2.0.4)
  - Locking sebastian/recursion-context (4.0.4)
  - Locking sebastian/resource-operations (3.0.3)
  - Locking sebastian/type (2.3.4)
  - Locking sebastian/version (3.0.2)
  - Locking swiftmailer/swiftmailer (v6.3.0)
  - Locking symfony/console (v5.4.1)
  - Locking symfony/css-selector (v6.0.1)
  - Locking symfony/deprecation-contracts (v3.0.0)
  - Locking symfony/error-handler (v5.4.1)
  - Locking symfony/event-dispatcher (v6.0.1)
  - Locking symfony/event-dispatcher-contracts (v3.0.0)
  - Locking symfony/finder (v5.4.0)
  - Locking symfony/http-foundation (v5.4.1)
  - Locking symfony/http-kernel (v5.4.1)
  - Locking symfony/mime (v5.4.0)
  - Locking symfony/polyfill-ctype (v1.23.0)
  - Locking symfony/polyfill-iconv (v1.23.0)
  - Locking symfony/polyfill-intl-grapheme (v1.23.1)
  - Locking symfony/polyfill-intl-idn (v1.23.0)
  - Locking symfony/polyfill-intl-normalizer (v1.23.0)
  - Locking symfony/polyfill-mbstring (v1.23.1)
  - Locking symfony/polyfill-php72 (v1.23.0)
  - Locking symfony/polyfill-php73 (v1.23.0)
  - Locking symfony/polyfill-php80 (v1.23.1)
  - Locking symfony/polyfill-php81 (v1.23.0)
  - Locking symfony/process (v5.4.0)
  - Locking symfony/routing (v5.4.0)
  - Locking symfony/service-contracts (v2.4.1)
  - Locking symfony/string (v6.0.1)
  - Locking symfony/translation (v6.0.1)
  - Locking symfony/translation-contracts (v3.0.0)
  - Locking symfony/var-dumper (v5.4.1)
  - Locking theseer/tokenizer (1.2.1)
  - Locking tijsverkoyen/css-to-inline-styles (2.2.4)
  - Locking vlucas/phpdotenv (v5.4.1)
  - Locking voku/portable-ascii (1.5.6)
  - Locking webmozart/assert (1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 110 installs, 0 updates, 0 removals
  - Installing doctrine/inflector (2.0.4): Extracting archive
  - Installing doctrine/lexer (1.2.1): Extracting archive
  - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive
  - Installing webmozart/assert (1.10.0): Extracting archive
  - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive
  - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
  - Installing symfony/var-dumper (v5.4.1): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive
  - Installing symfony/string (v6.0.1): Extracting archive
  - Installing psr/container (1.1.2): Extracting archive
  - Installing symfony/service-contracts (v2.4.1): Extracting archive
  - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.0.0): Extracting archive
  - Installing symfony/console (v5.4.1): Extracting archive
  - Installing psr/log (2.0.0): Extracting archive
  - Installing monolog/monolog (2.3.5): Extracting archive
  - Installing voku/portable-ascii (1.5.6): Extracting archive
  - Installing phpoption/phpoption (1.8.1): Extracting archive
  - Installing graham-campbell/result-type (v1.0.4): Extracting archive
  - Installing vlucas/phpdotenv (v5.4.1): Extracting archive
  - Installing symfony/css-selector (v6.0.1): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.4): Extracting archive
  - Installing symfony/routing (v5.4.0): Extracting archive
  - Installing symfony/process (v5.4.0): Extracting archive
  - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive
  - Installing symfony/mime (v5.4.0): Extracting archive
  - Installing symfony/http-foundation (v5.4.1): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.0.0): Extracting archive
  - Installing symfony/event-dispatcher (v6.0.1): Extracting archive
  - Installing symfony/error-handler (v5.4.1): Extracting archive
  - Installing symfony/http-kernel (v5.4.1): Extracting archive
  - Installing symfony/finder (v5.4.0): Extracting archive
  - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive
  - Installing egulias/email-validator (2.1.25): Extracting archive
  - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
  - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive
  - Installing ramsey/collection (1.2.2): Extracting archive
  - Installing brick/math (0.9.3): Extracting archive
  - Installing ramsey/uuid (4.2.3): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing opis/closure (3.6.2): Extracting archive
  - Installing symfony/translation-contracts (v3.0.0): Extracting archive
  - Installing symfony/translation (v6.0.1): Extracting archive
  - Installing nesbot/carbon (2.55.2): Extracting archive
  - Installing league/mime-type-detection (1.9.0): Extracting archive
  - Installing league/flysystem (1.1.9): Extracting archive
  - Installing nette/utils (v3.2.6): Extracting archive
  - Installing nette/schema (v1.2.2): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.1): Extracting archive
  - Installing league/config (v1.1.1): Extracting archive
  - Installing league/commonmark (2.1.0): Extracting archive
  - Installing laravel/serializable-closure (v1.0.5): Extracting archive
  - Installing laravel/framework (v8.77.1): Extracting archive
  - Installing facade/ignition-contracts (1.0.2): Extracting archive
  - Installing facade/flare-client-php (1.9.1): Extracting archive
  - Installing facade/ignition (2.17.3): Extracting archive
  - Installing fakerphp/faker (v1.17.0): Extracting archive
  - Installing asm89/stack-cors (v2.0.3): Extracting archive
  - Installing fruitcake/laravel-cors (v2.0.4): Extracting archive
  - Installing psr/http-message (1.0.1): Extracting archive
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-factory (1.0.1): Extracting archive
  - Installing guzzlehttp/psr7 (2.1.0): Extracting archive
  - Installing guzzlehttp/promises (1.5.1): Extracting archive
  - Installing guzzlehttp/guzzle (7.4.1): Extracting archive
  - Installing laravel/sail (v1.12.12): Extracting archive
  - Installing laravel/sanctum (v2.13.0): Extracting archive
  - Installing nikic/php-parser (v4.13.2): Extracting archive
  - Installing psy/psysh (v0.10.12): Extracting archive
  - Installing laravel/tinker (v2.6.3): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.4.4): Extracting archive
  - Installing filp/whoops (2.14.4): Extracting archive
  - Installing nunomaduro/collision (v5.10.0): Extracting archive
  - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
  - Installing phpdocumentor/type-resolver (1.5.1): Extracting archive
  - Installing phpdocumentor/reflection-docblock (5.3.0): Extracting archive
  - Installing sebastian/version (3.0.2): Extracting archive
  - Installing sebastian/type (2.3.4): Extracting archive
  - Installing sebastian/resource-operations (3.0.3): Extracting archive
  - Installing sebastian/recursion-context (4.0.4): Extracting archive
  - Installing sebastian/object-reflector (2.0.4): Extracting archive
  - Installing sebastian/object-enumerator (4.0.4): Extracting archive
  - Installing sebastian/global-state (5.0.3): Extracting archive
  - Installing sebastian/exporter (4.0.4): Extracting archive
  - Installing sebastian/environment (5.1.3): Extracting archive
  - Installing sebastian/diff (4.0.4): Extracting archive
  - Installing sebastian/comparator (4.0.6): Extracting archive
  - Installing sebastian/code-unit (1.0.8): Extracting archive
  - Installing sebastian/cli-parser (1.0.1): Extracting archive
  - Installing phpunit/php-timer (5.0.3): Extracting archive
  - Installing phpunit/php-text-template (2.0.4): Extracting archive
  - Installing phpunit/php-invoker (3.1.1): Extracting archive
  - Installing phpunit/php-file-iterator (3.0.6): Extracting archive
  - Installing theseer/tokenizer (1.2.1): Extracting archive
  - Installing sebastian/lines-of-code (1.0.3): Extracting archive
  - Installing sebastian/complexity (2.0.2): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
  - Installing phpunit/php-code-coverage (9.2.10): Extracting archive
  - Installing doctrine/instantiator (1.4.0): Extracting archive
  - Installing phpspec/prophecy (v1.15.0): Extracting archive
  - Installing phar-io/version (3.1.0): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.10.2): Extracting archive
  - Installing phpunit/phpunit (9.5.10): Extracting archive
63 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
77 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
> @php artisan key:generate --ansi
Application key set successfully.
lee@MacBook-Pro ~ % ls
Applications			Parallels
Desktop				Pictures
Documents			Public
Downloads			Sites
Library				Sunlogin Files
Movies				Virtual Machines.localized
Music				laraveldemo
OneDrive			sensors
lee@MacBook-Pro ~ % mv laraveldemo ./Downloads 
lee@MacBook-Pro ~ % ll
zsh: command not found: ll
lee@MacBook-Pro ~ % ls
Applications			Parallels
Desktop				Pictures
Documents			Public
Downloads			Sites
Library				Sunlogin Files
Movies				Virtual Machines.localized
Music				sensors
OneDrive
lee@MacBook-Pro ~ % ls 
Applications			Parallels
Desktop				Pictures
Documents			Public
Downloads			Sites
Library				Sunlogin Files
Movies				Virtual Machines.localized
Music				sensors
OneDrive
lee@MacBook-Pro ~ % cd Sites 
lee@MacBook-Pro Sites % ls
laraveldemo	localhost
lee@MacBook-Pro Sites % cd laraveldemo 
lee@MacBook-Pro laraveldemo % composer require nwidart/laravel-modules
Using version ^8.2 for nwidart/laravel-modules
./composer.json has been updated
Running composer update nwidart/laravel-modules
Loading composer repositories with package information
https://repo.packagist.org could not be fully loaded (curl error 28 while downloading https://repo.packagist.org/packages.json: Operation timed out after 10000 milliseconds with 0 out of 0 bytes received), package information was loaded from the local cache and may be out of date
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking nwidart/laravel-modules (8.2.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing nwidart/laravel-modules (8.2.0): Extracting archive
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Package manifest generated successfully.
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
lee@MacBook-Pro laraveldemo % php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

Copied File [/vendor/nwidart/laravel-modules/config/config.php] To [/config/modules.php]
Publishing complete.
lee@MacBook-Pro laraveldemo % php artisan module:make Admin
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/module.json
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Routes/web.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Routes/api.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Resources/views/index.blade.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Resources/views/layouts/master.blade.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Config/config.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/composer.json
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Resources/assets/js/app.js
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Resources/assets/sass/app.scss
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/webpack.mix.js
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/package.json
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Database/Seeders/AdminDatabaseSeeder.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Providers/AdminServiceProvider.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Providers/RouteServiceProvider.php
Created : /Users/lee/Sites/laraveldemo/Modules/Admin/Http/Controllers/AdminController.php
Module [Admin] created successfully.
lee@MacBook-Pro laraveldemo % composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Package manifest generated successfully.
Generated optimized autoload files containing 5099 classes
lee@MacBook-Pro laraveldemo % composer require "darkaonline/l5-swagger"
Using version ^8.0 for darkaonline/l5-swagger
./composer.json has been updated
Running composer update darkaonline/l5-swagger
Loading composer repositories with package information
Updating dependencies
Lock file operations: 6 installs, 0 updates, 0 removals
  - Locking darkaonline/l5-swagger (8.0.9)
  - Locking doctrine/annotations (1.13.2)
  - Locking psr/cache (3.0.0)
  - Locking swagger-api/swagger-ui (v3.52.5)
  - Locking symfony/yaml (v5.4.0)
  - Locking zircote/swagger-php (3.3.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 6 installs, 0 updates, 0 removals
  - Installing symfony/yaml (v5.4.0): Extracting archive
  - Installing psr/cache (3.0.0): Extracting archive
  - Installing doctrine/annotations (1.13.2): Extracting archive
  - Installing zircote/swagger-php (3.3.3): Extracting archive
  - Installing swagger-api/swagger-ui (v3.52.5): Extracting archive
  - Installing darkaonline/l5-swagger (8.0.9): Extracting archive
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: darkaonline/l5-swagger
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Package manifest generated successfully.
80 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
lee@MacBook-Pro laraveldemo % php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
Copied File [/vendor/darkaonline/l5-swagger/config/l5-swagger.php] To [/config/l5-swagger.php]
Copied Directory [/vendor/darkaonline/l5-swagger/resources/views] To [/resources/views/vendor/l5-swagger]
Publishing complete.
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default

   ErrorException 

  Required @OA\Info() not found

  at vendor/zircote/swagger-php/src/Logger.php:40
     36▕         $this->log = function ($entry, $type) {
     37▕             if ($entry instanceof Exception) {
     38▕                 $entry = $entry->getMessage();
     39▕             }
  ➜  40▕             trigger_error($entry, $type);
     41▕         };
     42▕     }
     43▕ 
     44▕     public static function getInstance(): Logger

      +27 vendor frames 
  28  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default

   ErrorException 

  Required @OA\Info() not found

  at vendor/zircote/swagger-php/src/Logger.php:40
     36▕         $this->log = function ($entry, $type) {
     37▕             if ($entry instanceof Exception) {
     38▕                 $entry = $entry->getMessage();
     39▕             }
  ➜  40▕             trigger_error($entry, $type);
     41▕         };
     42▕     }
     43▕ 
     44▕     public static function getInstance(): Logger

      +27 vendor frames 
  28  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default

   ErrorException 

  Required @OA\Info() not found

  at vendor/zircote/swagger-php/src/Logger.php:40
     36▕         $this->log = function ($entry, $type) {
     37▕             if ($entry instanceof Exception) {
     38▕                 $entry = $entry->getMessage();
     39▕             }
  ➜  40▕             trigger_error($entry, $type);
     41▕         };
     42▕     }
     43▕ 
     44▕     public static function getInstance(): Logger

      +27 vendor frames 
  28  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default

   ErrorException 

  Required @OA\PathItem() not found

  at vendor/zircote/swagger-php/src/Logger.php:40
     36▕         $this->log = function ($entry, $type) {
     37▕             if ($entry instanceof Exception) {
     38▕                 $entry = $entry->getMessage();
     39▕             }
  ➜  40▕             trigger_error($entry, $type);
     41▕         };
     42▕     }
     43▕ 
     44▕     public static function getInstance(): Logger

      +27 vendor frames 
  28  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

Publishing complete.
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan
Laravel Framework 8.77.1

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  clear-compiled              Remove the compiled class file
  completion                  Dump the shell completion script
  db                          Start a new database CLI session
  down                        Put the application into maintenance / demo mode
  env                         Display the current framework environment
  help                        Display help for a command
  inspire                     Display an inspiring quote
  list                        List commands
  migrate                     Run the database migrations
  optimize                    Cache the framework bootstrap files
  serve                       Serve the application on the PHP development server
  test                        Run the application tests
  tinker                      Interact with your application
  up                          Bring the application out of maintenance mode
 auth
  auth:clear-resets           Flush expired password reset tokens
 cache
  cache:clear                 Flush the application cache
  cache:forget                Remove an item from the cache
  cache:table                 Create a migration for the cache database table
 config
  config:cache                Create a cache file for faster configuration loading
  config:clear                Remove the configuration cache file
 db
  db:seed                     Seed the database with records
  db:wipe                     Drop all tables, views, and types
 event
  event:cache                 Discover and cache the application's events and listeners
  event:clear                 Clear all cached events and listeners
  event:generate              Generate the missing events and listeners based on registration
  event:list                  List the application's events and listeners
 key
  key:generate                Set the application key
 l5-swagger
  l5-swagger:generate         Regenerate docs
 make
  make:cast                   Create a new custom Eloquent cast class
  make:channel                Create a new channel class
  make:command                Create a new Artisan command
  make:component              Create a new view component class
  make:controller             Create a new controller class
  make:event                  Create a new event class
  make:exception              Create a new custom exception class
  make:factory                Create a new model factory
  make:job                    Create a new job class
  make:listener               Create a new event listener class
  make:mail                   Create a new email class
  make:middleware             Create a new middleware class
  make:migration              Create a new migration file
  make:model                  Create a new Eloquent model class
  make:notification           Create a new notification class
  make:observer               Create a new observer class
  make:policy                 Create a new policy class
  make:provider               Create a new service provider class
  make:request                Create a new form request class
  make:resource               Create a new resource
  make:rule                   Create a new validation rule
  make:seeder                 Create a new seeder class
  make:test                   Create a new test class
 migrate
  migrate:fresh               Drop all tables and re-run all migrations
  migrate:install             Create the migration repository
  migrate:refresh             Reset and re-run all migrations
  migrate:reset               Rollback all database migrations
  migrate:rollback            Rollback the last database migration
  migrate:status              Show the status of each migration
 model
  model:prune                 Prune models that are no longer needed
 module
  module:delete               Delete a module from the application
  module:disable              Disable the specified module.
  module:dump                 Dump-autoload the specified module or for all module.
  module:enable               Enable the specified module.
  module:install              Install the specified module by given package name (vendor/name).
  module:list                 Show list of all modules.
  module:make                 Create a new module.
  module:make-command         Generate new Artisan command for the specified module.
  module:make-controller      Generate new restful controller for the specified module.
  module:make-event           Create a new event class for the specified module
  module:make-factory         Create a new model factory for the specified module.
  module:make-job             Create a new job class for the specified module
  module:make-listener        Create a new event listener class for the specified module
  module:make-mail            Create a new email class for the specified module
  module:make-middleware      Create a new middleware class for the specified module.
  module:make-migration       Create a new migration for the specified module.
  module:make-model           Create a new model for the specified module.
  module:make-notification    Create a new notification class for the specified module.
  module:make-policy          Create a new policy class for the specified module.
  module:make-provider        Create a new service provider class for the specified module.
  module:make-request         Create a new form request class for the specified module.
  module:make-resource        Create a new resource class for the specified module.
  module:make-rule            Create a new validation rule for the specified module.
  module:make-seed            Generate new seeder for the specified module.
  module:make-test            Create a new test class for the specified module.
  module:migrate              Migrate the migrations from the specified module or from all modules.
  module:migrate-refresh      Rollback & re-migrate the modules migrations.
  module:migrate-reset        Reset the modules migrations.
  module:migrate-rollback     Rollback the modules migrations.
  module:migrate-status       Status for all module migrations
  module:publish              Publish a module's assets to the application
  module:publish-config       Publish a module's config files to the application
  module:publish-migration    Publish a module's migrations to the application
  module:publish-translation  Publish a module's translations to the application
  module:route-provider       Create a new route service provider for the specified module.
  module:seed                 Run database seeder from the specified module or from all modules.
  module:setup                Setting up modules folders for first use.
  module:unuse                Forget the used module with module:use
  module:update               Update dependencies for the specified module or for all modules.
  module:use                  Use the specified module.
  module:v6:migrate           Migrate laravel-modules v5 modules statuses to v6.
 notifications
  notifications:table         Create a migration for the notifications table
 optimize
  optimize:clear              Remove the cached bootstrap files
 package
  package:discover            Rebuild the cached package manifest
 queue
  queue:batches-table         Create a migration for the batches database table
  queue:clear                 Delete all of the jobs from the specified queue
  queue:failed                List all of the failed queue jobs
  queue:failed-table          Create a migration for the failed queue jobs database table
  queue:flush                 Flush all of the failed queue jobs
  queue:forget                Delete a failed queue job
  queue:listen                Listen to a given queue
  queue:monitor               Monitor the size of the specified queues
  queue:prune-batches         Prune stale entries from the batches database
  queue:prune-failed          Prune stale entries from the failed jobs table
  queue:restart               Restart queue worker daemons after their current job
  queue:retry                 Retry a failed queue job
  queue:retry-batch           Retry the failed jobs for a batch
  queue:table                 Create a migration for the queue jobs database table
  queue:work                  Start processing jobs on the queue as a daemon
 route
  route:cache                 Create a route cache file for faster route registration
  route:clear                 Remove the route cache file
  route:list                  List all registered routes
 sail
  sail:install                Install Laravel Sail's default Docker Compose file
  sail:publish                Publish the Laravel Sail Docker files
 schedule
  schedule:list               List the scheduled commands
  schedule:run                Run the scheduled commands
  schedule:test               Run a scheduled command
  schedule:work               Start the schedule worker
 schema
  schema:dump                 Dump the given database schema
 session
  session:table               Create a migration for the session database table
 storage
  storage:link                Create the symbolic links configured for the application
 stub
  stub:publish                Publish all stubs that are available for customization
 vendor
  vendor:publish              Publish any publishable assets from vendor packages
 view
  view:cache                  Compile all of the application's Blade templates
  view:clear                  Clear all compiled view files
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % php artisan l5-swagger:generate

Regenerating docs default
lee@MacBook-Pro laraveldemo % 
标签: Laravel8MACMAMP PRONUXTPhpStorm
上一篇文章

8小时转职Golang工程师

下一篇文章

[避坑指南] Laravel知多少(👤个人总结)

下一篇文章
laravel

[避坑指南] Laravel知多少(👤个人总结)

发表回复 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Search

没有结果
查看所有结果

About Me

个人随笔

Winston Lee

Programmer

Hello & welcome to my blog! My name is Winston Lee and am a programmer and am keen on sharing.

Winston Lee

About Me

Hello & welcome to my blog! My name is Winston Lee and am a programmer and am keen on sharing.

Categories

  • AJAX
  • BootStrap
  • CodeIgniter
  • CSS
  • DedeCMS
  • GIT
  • HTML
  • Javascript
  • Jquery
  • Laravel
  • Laravel在线教育平台
  • Linux
  • Memcache
  • MongoDB
  • MVC
  • Mysql
  • Nginx
  • Node
  • PDO
  • PHP
  • PHP7
  • PHP基本语法
  • PHP核心编程
  • Redis
  • Smarty
  • Socket
  • SVN
  • Swoole
  • TP3.2
  • TP3.2商城
  • TP5.0
  • TP5.0商城
  • XML
  • Yaf
  • Yii
  • Yii手机直播
  • 二次开发
  • 优化方案
  • 前端技术
  • 前端框架
  • 后台框架
  • 基本操作
  • 微信公众号
  • 数据库
  • 未分类
  • 混合APP
  • 源码Blog项目
  • 版本控制
  • 环境搭建
  • 移动端开发
  • 网站优化
  • 资料
  • 面向对象
  • 面向对象编程
  • 页面静态化

Tags

DOM Json RBAC 事件 传参 函数 分页 判断语句 匿名函数 变量 图片上传 存储过程 安装 对象 封装 属性 接口 控制器 数据库操作 数据类型 数据表 数组 文件上传 无刷新分页 权限 标签 模型 正则 流程控制 目录结构 算法 类 索引 继承 缩略图 表关系 视图 路由 运算符 选择器 递归 配置 错误处理 页面静态化 验证码
  • 首页
  • 前端
  • 前端框架
  • PHP
  • 数据库
  • 优化
  • 后台框架与实战
  • 移动开发
  • 二次开发
  • Linux
  • 版本控制
  • Node.js
  • 资料库

沪公网安备31011502400873 | 沪ICP备2024050435号-3

没有结果
查看所有结果
  • 首页
  • 前端
    • HTML
    • CSS
    • Javascript
    • XML
    • AJAX
  • 前端框架
    • BootStrap
    • Jquery
  • PHP
    • 语法
    • 核心
    • 面向对象
    • PHP7
    • Socket
    • Swoole
  • 数据库
    • Mysql
    • Redis
    • Memcache
    • MongoDB
  • 优化
    • 优化方案
    • 页面静态化
    • Nginx
  • 后台框架与实战
    • Smarty
    • 源码Blog
    • TP3.2
    • TP3.2商城
    • TP5.0
    • TP5.0商城
    • Laravel
    • Laravel在线教育平台
    • Yii
    • Yii手机直播
    • CodeIgniter
    • Yaf
  • 移动开发
    • 微信公众号
    • 混合APP
  • 二次开发
    • DedeCMS
  • Linux
    • 基本操作
    • 环境搭建
  • 版本控制
    • GIT
    • SVN
  • Node.js
  • 资料库

沪公网安备31011502400873 | 沪ICP备2024050435号-3