figaro figaro - 5 months ago 39
JSON Question

Is it possible to use Composer to manage Wordpress databases?

I am trying to use Composer for my Wordpress workflow and was wondering if there is a way for Composer to grab a MySQL database from my S3 bucket? The idea here is that I want to develop Wordpress websites locally starting from a backup copy of a database. Was hoping to find a way to automate this through Composer.


You can define custom scripts for composer, and tell it what you want to do.

For example, if you wanted to pull it from S3 and import it using the mysql command line utility, you could add something like this to composer.json:

"scripts": {
    "refresh-db": "aws s3 cp s3://my-bucket/db-dump.sql /tmp/db-dump.sql && mysql -hlocalhost -uroot my_db_name < /tmp/db-dump.sql"

Then run composer refresh-db to execute it.