承接 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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固