phinx icon indicating copy to clipboard operation
phinx copied to clipboard

Make cakephp/database an optional dependency

Open MasterOdin opened this issue 5 years ago • 7 comments

After looking at/doing #1753, I wondered if it would be possible to also make it so that there was not an explicit dependency on cakephp/database (which would in-turn solve #1647), and even potentially offering alternatives to it if someone so wanted.

The only thing that phinx relies on that library is to provide support for the getQueryBuilder() (AbstarctMigration) -> getQueryBuilder (Adapter) -> getDecoratedConnection (Adapter) -> cakephp/database. If it was made optional, this method would just raise an exception if cakephp/database does not exist, else operate as it does currently. I think this gives the best of all worlds here in that the overall installation cost of phinx is lowered, it does not pollute any namespace by default, and for those who want the query builder can use cakephp/database. For my own part, I do not use it in any of my projects as the few queries are simple enough to operate on all adapters as is).

Finally, it might make sense to specify an additional option of a query builder such as https://github.com/shadowhand/latitude, though make it clear that cakephp/database is the favored suggestion in docs and such.

MasterOdin avatar Apr 24 '20 03:04 MasterOdin

We just removed the collection package as dependency, but I don't think it is feasible to drop the main ORM layer here at this point.

dereuromark avatar Aug 04 '20 18:08 dereuromark

I dont think removing the dependency is a useful goal. If phinx stays under cake, it is probably best long-term to make it use the cake db connection.

othercorey avatar Aug 04 '20 22:08 othercorey

Dependency tree for cakephp/database v5 is even bigger than before, so it will make sense to make cakephp/database optional dependency. Are there any objections to do this?

For users searching for temporary workaround, add replace cakephp/database in composer.json:

{
    "require": {
        "robmorgan/phinx": "^2.0.2",
    }
    "replace": {
        "cakephp/database": "*",
    }
}

PabloKowalczyk avatar Sep 12 '23 09:09 PabloKowalczyk

Note: If https://github.com/cakephp/migrations/issues/647 gets traction, then this is actually very likely going to be possible. Just wanted to cross-link this for reference.

dereuromark avatar Oct 08 '23 23:10 dereuromark

I want to keep Phinx as little dependency as possible, so that I can run it in any framework without having to worry about so many compatibility issues

ajiho avatar Oct 11 '23 06:10 ajiho