cakephp / cakephp/phinx

Make cakephp/database an optional dependency

Open
#1,754 7 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing AbstractMigration::getQueryBuilder() through Adapter::getQueryBuilder() and Adapter::getDecoratedConnection(), then inspect how the cakephp/database dependency is declared. Define the behavior when cakephp/database is absent, including the exception path, and decide whether an alternative query builder such as Latitude is in scope. Done means the dependency is optional while the existing query-builder behavior remains available when installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.