phpmig icon indicating copy to clipboard operation
phpmig copied to clipboard

Bootstrap file

Open Petah opened this issue 14 years ago • 3 comments

Another feature for thought.

Instead of having a default php bootstrap file called phpmig.php, perhaps a configuration file would be better, such as .phpmig

A few reasons for this would be:

  • phpmig.php cannot be run standalone, and throws errors
  • phpmig.php is accessible (by default) with Apache (.phpmig would not be)
  • .phpmig could point to an appropriate bootstrap (or even multiple php files to be run)
  • .phpmig could point to the migrations directory
  • .phpmig would be more easily extendable to add extra properties in the future

The .phpmig format could be as simple as an INI, or perhaps even YAML, JSON, or XML

Petah avatar Nov 08 '11 00:11 Petah

I started out with a config file, but found it too inflexible. I like having the bootstrap as the main entry point, perhaps we could make the bootstrap an executable unto itself.

As for being accessible via apache, I don't think it makes any odds for me. If you can protect dot files, you can protect a single phpmig.php file?

That's not to say I'm against configuration files, they could have their place, but I'd rather it be secondary to the bootstrap. Just about every project I've come across has their own configuration and bootstrapping already, the phpmig bootstrap is there to try and take advantage of that.

davedevelopment avatar Nov 08 '11 08:11 davedevelopment

Perhaps phpmig could even look for both .phpmig and phpmig.php

Another reason I would perfer not to have a phpmig.php bootstrap is because my projects already have a bootstrap which makes models/DBs globally available. So I find it kinda pointless to have a bootstrap to call my bootstrap.

The Apache access is not so much of a major. It just by default any file starting with a . is hidden and not accessible. But yes you could configure Apache not to allow access to specific files.

Petah avatar Nov 08 '11 20:11 Petah

But do your projects have a config file? If so, wouldn't it be kind of pointless to have a phpmig config file, that calls your bootstrap, that calls your config file? And if that work wasn't done in the bootstrap file (that phpmig generates for you), phpmig would have to do it anyway?

I think it's just a differing of opinions. Like you say, in my projects, the project config file and the project bootstrap do all the hard work, like setting up services, switching config for development/testing/staging/production environments (which can be a lot of changes) and having phpmig piggy back off that is quick and easy.

If you feel that strongly about it, I'm happy to merge it in, as long as it doesn't replace the phpmig.php

Otherwise feel free to fork?

davedevelopment avatar Nov 08 '11 21:11 davedevelopment