Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using git version control for PHP development

Is it possible to version control a PHP + MySQL + Apache project? And could it keep track of the changes in the database, like for example if I added a new table, can I possibly commit that?

Thank you.

like image 385
Jezer Crespo Avatar asked Jun 19 '26 14:06

Jezer Crespo


2 Answers

It is not normal to keep databases in version control. Some developers use a sqlite database for development so that it can be checked into version control, but this can lead to issues as sqlite syntax can be different from MySQL.

However, you can keep your database schema and migrations source control. Look at a projects such as mysql-php-migrations to get started.

There's a good tutorial on using PHP with Git at http://net.tutsplus.com/tutorials/other/easy-version-control-with-git/ - this should get you started.

like image 50
iHiD Avatar answered Jun 21 '26 04:06

iHiD


Using Git for your PHP scripts is no problem, however tracking changes to the database is a little trickier. If you have SQL scripts that create the database structure then these can be version controlled with no problems. Otherwise you could use mysqldump to output the structure to an SQL script after any changes you make:

mysqldump -d -h localhost -u root -pmypassword mydatabase > dumpfile.sql 
like image 20
John Lawrence Avatar answered Jun 21 '26 05:06

John Lawrence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!