donglian3061
2015-09-16 21:02 阅读 38

git中的Wordpress数据库[关闭]

I'm trying to set up a workflow that allows me to develop a single Wordpress theme locally on both my home machine and my laptop since I spend quite a bit of time away. I use git to keep my files all synced up but the issue I'm finding is the database. Currently I can only run Wordpress successfully in the machine I install it in, the other giving me the "Error establishing a database connection", definitely expected as I don't push the database up. My question is, how do I include the Wordpress database in my git repo? Or if that's not possible (or wouldn't even work anyway) is there a way to successfully develop a Wordpress theme on two machines both locally? This front-end dev would really appreciate all you awesome back-end gurus' assistance!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    du6333137 du6333137 2015-09-16 21:07

    The feature you are trying to achieve is called Database Migrations, which is not currently possible using plain PHP and with Git, it is definitely not possible. What you can do is to use some other alternatives like those below:

    1. Ruckusing

      Ruckusing is a framework written in PHP5 for generating and managing a set of "database migrations". Database migrations are declarative files which represent the state of a DB (its tables, columns, indexes, etc) at a particular state of time. By using database migrations, multiple developers can work on the same application and be guaranteed that the application is in a consistent state across all remote developer machines.

      The idea of the framework was borrowed from the migration system built into Ruby on Rails. Any one who is familiar with Migrations in RoR will be immediately at home.

    2. Phinx: Simple PHP Database Migrations

      Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minutes you can install Phinx and create your first database migration. Phinx is just about migrations without all the bloat of a database ORM system or framework.

    3. Phpmig

      Phpmig is a (database) migration tool for php, that should be adaptable for use with most PHP 5.3+ projects. It's kind of like doctrine migrations, without the doctrine. Although you can use doctrine if you want. And ironically, I use doctrine in my examples.

    点赞 评论 复制链接分享

相关推荐