cakephp / cakephp/phinx

Seeds with namespaces need to be specified by their fully qualified class name

Open
#2,201 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently, when using the -s option when running seeds with namespaces, the seeds need to be referred to by their fully qualified class name, and cannot be run with only their base class name.

My paths configuration is as follows

{
    "paths": {
        "migrations": {
            "Something\\Database\\Migrations\\Global": "%%PHINX_CONFIG_DIR%%/src/Migrations/Global"
        },
        "seeds": {
            "Something\\Database\\Seeds\\Global": "%%PHINX_CONFIG_DIR%%/src/Seeds/Global",
            "Something\\Database\\Seeds\\Global\\Dev": "%%PHINX_CONFIG_DIR%%/src/Seeds/Global/Dev"
        }
    }
}

A seed class called "ExampleSeeder" located in "%%PHINX_CONFIG_DIR%%/src/Seeds/Global" with a namespace of "Something\Database\Seeds\Global" still needs to be run with its fully qualified class name when run with the following command ./bin/phinx seed:run -s "Something\\\Database\\\Seeds\\\Global\\\ExampleSeeder". The command ./bin/phinx seed:run -s "ExampleSeeder" will report an error that the seed class does not exist.

Going over the code, this seems to be intentional and not a bug. Is there some other configuration setting that I'm missing which would enable the seed:run method to run with merely the class name? This would make running them by hand much less laboursome, especially when using multiple namespaces and multiple seed folders.

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 with the ./bin/phinx seed:run entry point and the shown paths.seeds configuration, then trace how the -s value is resolved for namespaced seed classes. Confirm the behavior with the provided namespace and ExampleSeeder setup; done means the base class name can select the seed without its fully qualified name.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.