问答 / 1 / 12 / 创建于 1年前
我现在给客户部署好了应用,想在后台加一个一件更新的功能,如何实现呢?要是数据库结构也一起需要更新呢?
不了解我个人想法: 利用 command 来执行,参考数据库迁移。
command
如5个版本: v2 v3 v4 v5 v6
如果用户处于 v1 版, 则执行 update:v2… update:v6
v1
update:v2
update:v6
UpdateV2Command.php 代码类似:
UpdateV2Command.php
public function handle(){ $this->up(); # $this->down(); } public function up(){ # 更新版本 # 更新代码 Storage::disk('自定义')->put('xxx.php',file_get_contents('xxx.php')) # 改变数据库结构 Schema::table('xxx', function (Blueprint $table): void { $table->string('hello'); }); } public function down(){ # 回退版本 Schema::table('xxx', function (Blueprint $table): void { $table->dropField('hello'); }); }
@wongvio不懂为什么会影响 git
git
文件可以随便放 如: storage/version/2/xxxController.php(不推荐远程 毕竟网络可能是问题 )
storage/version/2/xxxController.php
@wongvio我没想过 项目多 可以考虑
我想法 直接创建 自定义配置文件 解析配置 然后运行。对于小应用 简单些。
类似这样?:博客:给大家一个小惊喜,Laravel 插件,从 packagist.org 自动安装到项目...
还有这样?分享创造:Plugin Manager: 让 Laravel 应用更具组织性和可扩展性
我要举报该,理由是:
不了解
我个人想法: 利用
command
来执行,参考数据库迁移。如5个版本: v2 v3 v4 v5 v6
如果用户处于
v1
版, 则执行update:v2
…update:v6
UpdateV2Command.php
代码类似:类似这样?:博客:给大家一个小惊喜,Laravel 插件,从 packagist.org 自动安装到项目...
还有这样?分享创造:Plugin Manager: 让 Laravel 应用更具组织性和可扩展性