定制 waelwalid/laravel-database-sync 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

waelwalid/laravel-database-sync

Composer 安装命令:

composer require waelwalid/laravel-database-sync

包简介

Helper scripts to quickly synchronise a local MySQL database with a remote database, as well as prepare a local database for deployment to a remote server.

README 文档

README

When working on an active project, your local database may become too out of date from the database in staging or production and make local development difficult or unpredictable.

DB Sync provides scripts to quickly update a local MySQL development database with a remote staging or production database, as well as the ability to run safe search/replace on your local database in preparation for deploying to a remote server. It assumes that your remote database is externally accessable via an IP whitelist or similar.

Disclaimer: These scripts and commands were originally created for use internally within our development team to speed up common, repetitive tasks. However, they may be of some use to others. Feel free to use in your own projects, your mileage may vary.

Requirements

  • Composer
  • PHP >= 5.3.0
  • A local development environment, such as Vagrant.

Notes

  • These scripts require a .env config file in the project root . however it should work with other projects, such as Laravel 5.

Installation

Run composer require "waelwalid/laravel-database-sync:1.*" --dev from the root of your project.

Alternatively, you can manually add "waelwalid/laravel-database-sync": "1.*" to your composer.json file:

"require-dev": {
	"waelwalid/laravel-database-sync": "1.*"
}

Then add the following scripts to your composer.json file:

"scripts": {
	"database-update" : [
		"vendor/waelwalid/laravel-database-sync/database-update.sh"
	],
	"database-prepare" : [
		"vendor/waelwalid/laravel-database-sync/database-prepare.sh"
	],
	"database-import" : [
		"vendor/waelwalid/laravel-database-sync/database-import.sh"
	],
	"database-export" : [
		"vendor/waelwalid/laravel-database-sync/database-export.sh"
	]
}

Run the composer update command from the root of your project.

Create a .env file in the root of your project and add/update the following configuration options:

DOMAIN_REMOTE=www.example.com
DOMAIN_LOCAL=www.example.local

DB_HOST=localhost
DB_DATABASE=example
DB_USERNAME=root
DB_PASSWORD=password

REMOTE_DB_HOST=123.123.123.123
REMOTE_DB_DATABASE=example
REMOTE_DB_USERNAME=root
REMOTE_DB_PASSWORD=password

Usage

From the root of your project, you will be able to run the following composer commands:

  • composer database-update - When working on an active project, your local database might become too out of date from the database in staging or production. This command will backup and empty your locally configured database and update it with a copy of your remote or production database. This requires all DB_* and REMOTE_DB_* options to be set in the .env file and also assumes your remote database is accessible externally.

  • composer database-prepare - When developing locally, links to images and assets created within a CMS might be referencing your local development web address and won't work in staging or production. This command will run a safe search/replace script on your locally configured database, replacing all instances of DOMAIN_LOCAL with DOMAIN_REMOTE configured in the .env file. The database will then be exported to dumps/prepared-database-YYYY.MM.DD-HH.MM.SS.sql ready for deployment.

  • composer database-import - If the file setup/database.sql exists in the project root, this command will import the file into your local database configured in the .env file. This is useful if you're working on a project and want another member of the team to get quickly set up with working copy of the database.

  • composer database-export - This command will export a copy of your local database configured in the .env file and save it to setup/database.sql. If this file exists it will be overwritten. This is useful to quickly take a snapshot of your current development database to be shared with others.

Config

See below for an explanation of each configuration option used within the .env file.

  • DOMAIN_REMOTE - It should point to your remote or production environment (if available) and not include http:// or trailing slashes. Example: www.example.com or subdomain.example.com.

  • DOMAIN_LOCAL - It should not include http:// or trailing slashes. Example: www.example.local or subdomain.example.local.

  • DB_* - Provides options to set the local database connection details.

  • REMOTE_DB_* - Provides options to set the remote staging or production database connection details.

Donate

If you like this package, don't hesitate to give it a Start or donate via Paypal .

waelwalid/laravel-database-sync 适用场景与选型建议

waelwalid/laravel-database-sync 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 320 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 waelwalid/laravel-database-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 waelwalid/laravel-database-sync 我们能提供哪些服务?
定制开发 / 二次开发

基于 waelwalid/laravel-database-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 320
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 5
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-22