雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

PHP編程

當(dāng)前位置:主頁(yè) > 網(wǎng)絡(luò)編程 > PHP編程 >

Laravel 微信小程序后端搭建步驟詳解

來源:本站原創(chuàng)|時(shí)間:2020-01-11|欄目:PHP編程|點(diǎn)擊:

1. 新建個(gè) laravel 項(xiàng)目

laravel new aaaa 

2. 執(zhí)行命令運(yùn)行起站點(diǎn)來

php artisan key:generate

3. 登錄裝著 mysql 服務(wù)的遠(yuǎn)程服務(wù)器,創(chuàng)建數(shù)據(jù)庫(kù)及用戶名

(1)登錄 ssh root@218.45.23.456

(2)登錄 mysql 輸入命令 mysql -u root -p,輸入密碼登錄成功顯示 mysql>

(3)創(chuàng)建數(shù)據(jù)庫(kù) create database aaaaaaaa charset utf8mb4;

(4)創(chuàng)建遠(yuǎn)程用戶 create user aaaa@‘%' identified by ‘密碼';

(5)賦權(quán) grant all privileges on aaaaaaaa.* to aaaa@“%”;

4. 改下 database/migrations 目錄下的 **users_table.php 文件,添加上微信開放的字段

//微信資料
$table->string(‘weapp_openid')->nullable()->comment(‘微信開放id');
$table->string(‘weapp_session_key')->nullable()->comment(‘微信session_key');
$table->string(‘nickname')->nullable()->comment(‘昵稱');
$table->string(‘weapp_avatar')->nullable()->comment(‘微信頭像');
$table->string(‘country')->nullable()->comment(‘國(guó)家');
$table->string(‘province')->nullable()->comment(‘省份');
$table->string(‘city')->nullable()->comment(‘所在城市');
$table->string(‘language')->nullable()->comment(‘語(yǔ)言');
$table->json(‘location')->nullable()->comment(‘當(dāng)前地理信息');
$table->enum(‘gender', [‘1', ‘2'])->default(‘1')->comment(‘性別默認(rèn)男');
$table->string(‘phone')->nullable()->unique();

5. 打開 config/app.php 把時(shí)區(qū)、語(yǔ)言換下

‘timezone' => ‘Asia/Shanghai',
‘locale' => ‘zh-CN',
‘fallback_locale' => ‘zh-CN',
‘faker_locale' => ‘zh-CN',

6. 打開 composer.json

require 里添加下面幾個(gè)包

“require”: {
 “php”: “^7.1.3”,
 “fideloper/proxy”: “^4.0”,
 “l(fā)aravel/framework”: “5.8.*”,
 “l(fā)aravel/tinker”: “^1.0”,
 “jellybool/flysystem-upyun”: “^1.0”,
 “l(fā)aravel/passport”: “^7.2”,
 “overtrue/laravel-wechat”: “~5.0”
},

7. 命令行執(zhí)行 composer update

打開參照鏈接配置下

(1)又拍云參照配置 https://github.com/JellyBool/flysystem-upyun

(2)easywechart 參照配置 GitHub - overtrue/laravel-wechat: 微信 SDK for Laravel, 基于 overtrue/wechat

8.app/Http/Kernel.php 接口設(shè)置次數(shù)多些

‘a(chǎn)pi' => [
 ‘throttle:60000,1',
 ‘bindings',
],

9. 打開.env 文件,配置好數(shù)據(jù)庫(kù)和小程序、又拍云的保密信息

DB_CONNECTION=mysql
DB_HOST=218.45.23.456
DB_PORT=3306
DB_DATABASE=aaaaaaaa
DB_USERNAME=aaaa
DB_PASSWORD=密碼

UP_OPERATOR_NAME=又拍云ftp用戶名
UP_OPERATOR_PASSWORD=又拍云ftp密碼

WECHAT_MINI_PROGRAM_APPID=小程序APPID
WECHAT_MINI_PROGRAM_SECRET=小程序SECRET

10. 執(zhí)行 php artisan migrate,生成數(shù)據(jù)庫(kù)表 7 張表

Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrated: 2016_06_01_000001_create_oauth_auth_codes_table
Migrated: 2016_06_01_000002_create_oauth_access_tokens_table
Migrated: 2016_06_01_000003_create_oauth_refresh_tokens_table
Migrated: 2016_06_01_000004_create_oauth_clients_table
Migrated: 000005_create_oauth_personal_access_clients_table

11. 執(zhí)行命令 php artisan passport:install

Client ID: 1
Client secret:
Password grant client created successfully.
Client ID: 2
Client secret:

12.config/auth.php,API 的 dirver 改成 passport

'api' => [
   'driver' => 'passport',
   'provider' => 'users',
   'hash' => false,
  ],

一開始差不多就這些吧

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:Laravel框架Blade模板簡(jiǎn)介及模板繼承用法分析

欄    目:PHP編程

下一篇:在phpstudy集成環(huán)境下的nginx服務(wù)器下配置url重寫

本文標(biāo)題:Laravel 微信小程序后端搭建步驟詳解

本文地址:http://www.jygsgssxh.com/a1/PHPbiancheng/11079.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有