Keeping software updated can be very time consuming because let’s face it, software runs our lives. Unless you’ve been living in the forest the past 20 years, you use software daily. As a Developer, I use phpMyAdmin, it’s my app of choice when managing databases because it runs smoothly, and it’s free. I love free, don’t you?
Now there comes a time in a Developer’s life when he/she needs to upgrade their phpMyAdmin installation. But since it’s one of those things that isn’t entirely “urgent” for the most part, security updates aside, we tend to put off upgrading until we start to see rust (metaphorically speaking).
Automatic upgrades for phpMyAdmin
I’m going to assume you’re using a Linux/Unix server, and know how to use the command line, since that’s the way I roll. If you don’t have git installed, just type:
sudo apt-get install git-core
Now let’s grab the latest phpMyAdmin code:
cd ~/workspace git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git
This says, go into my home/workspace directory, and pull the latest version from git, but not the entire git history.
Next, let’s create a command line script to run the updates. I’m a Florida PHP Developer, so we’ll use PHP. Name the script update_phpmyadmin.php for simplicity.
#!/usr/bin/php <?php $cmd = "cd /home/YOUR_USER/workspace/phpmyadmin;git pull -q origin STABLE"; shell_exec($cmd);
Before being able to use this script, we need to make it executable; type this:
sudo chmod 700 /path/to/update_phpmyadmin.php
Finally, let’s schedule the task with cron so it runs automatically:
# Automatically upgrade phpMyAdmin daily (1:00am) 0 1 * * * * /path/to/update_phpymyadmin.php >/dev/null
There you go, you’re automagically updating your phpMyAdmin install.
Why not use apt-get or yum or brew?
You might be asking why not just use apt-get or yum or brew (MAC) to automatically update phpMyAdmin. The answer is simple. You want the latest from phpMyAdmin, and apt-get/yum tend to fall behind. If you want the latest phpMyAdmin, use this approach.
Conclusion
You just learned how to get phpMyAdmin to auto update. Use with caution; not responsible if you break something. Should you need PHP Developer help, contact us for a quote.
Disclaimer
Please confirm your code works locally before pushing to a web server. Please eyeball the code before running it to confirm it will not destroy you system. Not responsible for any damages.
It worked well from the start. But after a few updates I noticed that my phpmyadmin/.git folder size became 3.4 Gygabytes. It’s unacceptable for me so I decided to find another solution.
Hi Ilya, that’s really odd that it would be that large after a few updates. You could add git gc to the script to keep your .git directory within reason.
Hi, I’m not very much familiar with git, I know basics only. I tried git gc and it was running for more than half hour consuming 100% CPU and quite a good part of RAM until I killed it. So I just erased the .git folder and created my own php script:
It sends http HEAD request to https://raw.githubusercontent.com/phpmyadmin/phpmyadmin/STABLE/ChangeLog
Then if response header ‘Content-Length’ is different from current ChangeLog filesize it downloads https://github.com/phpmyadmin/phpmyadmin/archive/STABLE.zip and upacks it.
What do you think of this approach?
I can share the code if you like.
I’m wondering if you forgot to include depth=1 in the first command. Did your first command look like this?
git clone –depth=1 –branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git
and about downloading language-translation modules? how automate it?