Laravel 微信小程序后端搭建步驟詳解
1. 新建個 laravel 項目
laravel new aaaa
2. 執(zhí)行命令運行起站點來
php artisan key:generate
3. 登錄裝著 mysql 服務的遠程服務器,創(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)賦權 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(‘當前地理信息'); $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ù)多些
‘api' => [ ‘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, ],
一開始差不多就這些吧
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持我們。
上一篇:Laravel框架Blade模板簡介及模板繼承用法分析
欄 目:PHP編程
下一篇:在phpstudy集成環(huán)境下的nginx服務器下配置url重寫
本文地址:http://mengdiqiu.com.cn/a1/PHPbiancheng/11079.html
您可能感興趣的文章
- 01-11Laravel框架Blade模板簡介及模板繼承用法分析
- 01-11Laravel 微信小程序后端實現(xiàn)用戶登錄的示例代碼
- 01-11Laravel框架基礎語法與知識點整理【模板變量、輸出、include引入
- 01-11Laravel框架Eloquent ORM刪除數(shù)據(jù)操作示例
- 01-11Laravel框架Eloquent ORM修改數(shù)據(jù)操作示例
- 01-11Laravel框架Eloquent ORM簡介、模型建立及查詢數(shù)據(jù)操作詳解
- 01-11php實現(xiàn)快速對二維數(shù)組某一列進行組裝的方法小結
- 01-11laravel5.1框架下的批量賦值實現(xiàn)方法分析
- 01-11laravel5.5框架的上傳圖片功能實例分析【僅傳到服務器端】
- 01-11Laravel框架下載,安裝及路由操作圖文詳解


閱讀排行
本欄相關
- 04-02php本站才可以請求數(shù)據(jù) php本地數(shù)據(jù)庫
- 04-02關于txt數(shù)據(jù)庫php的信息
- 04-02php打印請求數(shù)據(jù) php打印輸出結果
- 04-02網(wǎng)頁里php操作數(shù)據(jù)庫 php網(wǎng)頁例子
- 04-02php插入數(shù)據(jù)庫為亂碼 php連接數(shù)據(jù)庫亂
- 04-02php數(shù)據(jù)庫地址 phpstudy 數(shù)據(jù)庫
- 04-02php數(shù)據(jù)庫數(shù)據(jù)相加 php數(shù)據(jù)庫添加數(shù)據(jù)
- 04-02數(shù)據(jù)權限架構思路php 數(shù)據(jù)權限設計方
- 04-02php數(shù)據(jù)庫輸入變量 php里輸出數(shù)據(jù)庫數(shù)
- 04-02php如何用導入數(shù)據(jù) php用來導入其他文
隨機閱讀
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 01-10SublimeText編譯C開發(fā)環(huán)境設置
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-11ajax實現(xiàn)頁面的局部加載
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10C#中split用法實例總結
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 04-02jquery與jsp,用jquery