PHP code example of lcli / app-vcs
1. Go to this page and download the library: Download lcli/app-vcs library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lcli / app-vcs example snippets
return [
// 项目标识(🉑必填) 同一台服务器上唯一,自行生成,不能含有特殊字符或中文,可由数字、字母、下划线、.点 -杠、组成的唯一标识
'project_id' => '',
// 服务地址(🔅必填)
'server_url' => 'https://www.baidu.com',
// 客户端ID(🉑非必填)
'client_id' => '',
// 应用ID (🔅必填)
'app_id' => '',
// 执行时生成的临时文件进行存储的目录(非必填)
'temp_file_path' => '',
// 备份目录 (🉑非必填)
'backup_path' => '',
// 安装sdk的服务端目录 (🔅必填)
'root_path' => dirname(__DIR__),
// 项目目录 需要更新的代码目录 (🔅必填)
'project_path' => dirname(__DIR__),
// 数据库配置(🉑非必填)
'database' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => 3306,
'database' => 'lhr_app',
'username' => 'root',
'password' => '',
],
];
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
return [
/*
|--------------------------------------------------------------------------
| 服务地址
|--------------------------------------------------------------------------
|
| 版本管理平台API地址, 填写规范: http://host:port/,
| 结尾必须带上 "/"
|
*/
'server_url' => 'http://dev.app-vcs.com/',
/*
|--------------------------------------------------------------------------
| 客户端ID
|--------------------------------------------------------------------------
|
| 从版本管理平台中创建获取
|
*/
'client_id' => 'client-test-1',
/*
|--------------------------------------------------------------------------
| 应用ID
|--------------------------------------------------------------------------
|
| 从版本管理系统中创建获取
|
*/
'app_id' => 'gentou',
/*
|--------------------------------------------------------------------------
| 网站本地存储目录
|--------------------------------------------------------------------------
|
| 本地根目录地址, 例如thinkphp的根目录在: www/wwwroot/xxx/public,
| 那么必须填写绝对路径地址: /www/wwwroot/xxx/public
|
*/
'root_path' => app()->getRootPath(),
/*
|--------------------------------------------------------------------------
| 数据库地址
|--------------------------------------------------------------------------
|
| 安装升级时,需要备份数据库,这里填写备份地址
|
*/
'database' => [
// 数据库类型
'driver' => 'mysql',
// 服务器地址
'host' => '127.0.0.1',
// 数据库端口
'port' => 3306,
// 数据库名
'database' => 'tzkj_gentou',
// 用户名
'username' => 'root',
// 密码
'password' => 'root',
],
];
$appVcs = new \Lcli\AppVcs\AppVcs();
$check = $appvcs->check();
$appvcs = new AppVcs();
$upgradeResult = $appvcs->upgrade();
$appvcs = new AppVcs();
$upgradeResult = $appvcs->getVersion();
tag命名规范为: 1.0.0, 1.0.1, 1.0.2, 1.0.3, ...(不包含v字符)
新增文件回滚测试:v1.1.11
[测试]新增文件回滚测试
[修复]修复v1.1.10数据库迁移失败
迁移文件内容是sql文件, 内容规范为:
-- {表名:用于备份对应客户端的表}
执行语句....
例如:
-- lmq_demo
CREATE TABLE lmq_demo (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);
-- lmq_demo
ALTER TABLE lmq_demo ADD COLUMN `describe` VARCHAR(255);
bash
php vendor/bin/appvcs init
bash
php vendor/bin/appvcs help