1. 新建個 laravel 項目
laravel new aaaa
2. 執(zhí)行命令運行起站點來
php artisan key:generate
3. 登錄裝著 mysql 服務(wù)的遠程服務(wù)器,創(chuàng)建數(shù)據(jù)庫及用戶名
(1)登錄 ssh root@218.45.23.456
(2)登錄 mysql 輸入命令 mysql -u root -p,輸入密碼登錄成功顯示 mysql>
(3)創(chuàng)建數(shù)據(jù)庫 create database aaaaaaaa charset utf8mb4;
(4)創(chuàng)建遠程用戶 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(‘國家'); $table->string(‘province')->nullable()->comment(‘省份'); $table->string(‘city')->nullable()->comment(‘所在城市'); $table->string(‘language')->nullable()->comment(‘語言'); $table->json(‘location')->nullable()->comment(‘當(dāng)前地理信息'); $table->enum(‘gender', [‘1', ‘2'])->default(‘1')->comment(‘性別默認男'); $table->string(‘phone')->nullable()->unique();
5. 打開 config/app.php 把時區(qū)、語言換下
‘timezone' => ‘Asia/Shanghai', ‘locale' => ‘zh-CN', ‘fallback_locale' => ‘zh-CN', ‘faker_locale' => ‘zh-CN',
6. 打開 composer.json
require 里添加下面幾個包
“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ù)庫和小程序、又拍云的保密信息
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ù)庫表 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, ],
一開始差不多就這些吧
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
標(biāo)簽:江門 雙鴨山 石嘴山 深圳 內(nèi)江 大同 駐馬店 巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Laravel 微信小程序后端搭建步驟詳解》,本文關(guān)鍵詞 Laravel,微信,小,程序,后端,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。