Laravel⼩程序后端搭建步骤详解1. 新建个 laravel 项⽬
laravel new aaaa
2. 执⾏命令运⾏起站点来
php artisan key:generate
3. 登录装着 mysql 服务的远程服务器,创建数据库及⽤户名
(1)登录 ssh root@218.45.23.456
(2)登录 mysql 输⼊命令 mysql -u root -p,输⼊密码登录成功显⽰ mysql>
(3)创建数据库 create database aaaaaaaa charset utf8mb4;
(4)创建远程⽤户 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 把时区、语⾔换下
‘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”,
“laravel/framework”: “5.8.*”,
“laravel/tinker”: “^1.0”,
“jellybool/flysystem-upyun”: “^1.0”,
“laravel/passport”: “^7.2”,
“overtrue/laravel-wechat”: “~5.0”
},
7. 命令⾏执⾏ composer update
打开参照链接配置下
(2)easywechart 参照配置
8.app/Http/Kernel.php 接⼝设置次数多些
‘api' => [
‘throttle:60000,1',
‘bindings',
],
9. 打开.env ⽂件,配置好数据库和⼩程序、⼜拍云的保密信息
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. 执⾏ php artisan migrate,⽣成数据库表 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. 执⾏命令 php artisan passport:install
Client ID: 1
Client secret:
Password grant client created successfully.
Client ID: 2
Client secret:
'api' => [
php项目搭建'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
⼀开始差不多就这些吧
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论