定制 samhernandez/craft-db-paths 二次开发

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

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

samhernandez/craft-db-paths

Composer 安装命令:

composer require samhernandez/craft-db-paths

包简介

Fix failed Craft backups and restores with full paths to psql, mysql, and mysqldump executables.

README 文档

README

Skip to the usage instructions if you already know the story.

Background

Craft relies by default on the mysqldump and mysql executables to backup and restore databases. The default backup command looks like this:

mysqldump […options…] {database} > {file}'

The problem is that, while mysqldump might be available in the system, PHP running under a web request doesn’t know where to find it because it’s not in any directories specified in the PATH environmental variable. This is true when running locally with MAMP. It’s also true sometimes on EC2 instances when running MariaDB on RDS.

For this reason, Craft provides two configuration variables for you: backupCommand and restoreCommand. You can write your own command with the full path to the mysqldump executable. For MAMP it might be something like this:

/Applications/MAMP/Library/bin/mysqldump […options…] {database} > {file}

The thing is, Craft’s default dump command is really nice. It excludes unnecessary session, cache, and asset data. You can see how it’s built for MySQL in the Schema::defaultBackupCommand() method. What if you could just replace mysqldump with its full path and not have to roll your own command? That's what this module is for.

Usage

Installation

This is a module for Craft CMS, not a plugin available in Craft's Plugin Store. It is installed with composer on the command line.

Run the following command in the root of your project.

composer require samhernandez/craft-db-paths

Open /config/app.php, add the CraftDbPaths class as a module, and bootstrap it. Example:

return [
    'modules' => [
        'craft-db-paths' => \samhernandez\craftdbpaths\CraftDbPaths::class,
    ],
    'bootstrap' => ['craft-db-paths'],
];

Configuration

Add any of the following env vars to your .env file. Here is an example for MAMP on a Mac with MySQL.

PATH_TO_MYSQL=/Applications/MAMP/Library/bin/mysql
PATH_TO_MYSQLDUMP=/Applications/MAMP/Library/bin/mysqldump

If necessary, you can add paths for Postgres too.

PATH_TO_PSQL=/usr/local/bin/psql
PATH_TO_PGDUMP=/usr/local/bin/pg_dump

No configuration file is necesary, just env variables set in your .env or otherwise.

samhernandez/craft-db-paths 适用场景与选型建议

samhernandez/craft-db-paths 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 965 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mysql」 「backup」 「psql」 「mysqldump」 「Craft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 samhernandez/craft-db-paths 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 965
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-03