I am writing a script to take care of my database migrations. I don't like using phinx, it doesn't allow for easy migrations for multiple databases.
My migrations are in directory
migrations/
I have read this question, and used it.
PHP script to loop through all of the files in a directory?
foreach (glob("migrations/*.php") as $filename) {
require_once $filename;
$t = explode(".",$filename);
$obj = strtolower($t[1]);
$class = explode("/", $t[0]);
${$obj}= new $class[1](); // make object from the class name
${$obj}->up();
}
The file in migrations/ is Directory.php, it is a migration for the directory database, it has a method up() which I am trying to call. I want to run this script after provisioning, or manually via command line. It seems to be constructing the class ok. Getting the following error though...
PHP Fatal error: Call to undefined method Directory::up()