getDependencies() doesn't work nicely with namespaced seeders
Open
Nobody has claimed this yet.
support
- Dominant language
- PHP
- Stars
- 4.5k
- Forks
- 884
- PR merge metrics
- No merged PRs in 30d
Description
Hey, I'm trying to get getDependencies() to work with namespaced seeders.
I have the following code:
<?php
namespace Database\Seeders;
use Phinx\Seed\AbstractSeed;
class CarSeed extends AbstractSeed{
public function run(){
$this->table('cars')
->insert([
[
'name' => 'Ford Mustang',
'color' => 'blue',
'garageId' => 1
]
->save();
}
public function getDependencies(){
return [
'Database\Seeders\GarageSeed'
];
}
}
And
<?php
namespace Database\Seeders;
use Phinx\Seed\AbstractSeed;
class GarageSeed extends AbstractSeed{
public function run(){
$this->table('garages')
->insert([
[
'name' => 'MyGarage'
]
->save();
}
}
If I try to run this I get the following error:
In Manager.php line 848:
Could not find class "GarageSeed" in file "/var/www/html/app/database/s
eeds/GarageSeed.php"
Is there any easy solution for this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Manager.php around line 848 and reproduce the issue with app/database/seeds/GarageSeed.php and CarSeed.php. Trace how getDependencies() resolves the fully qualified class name against the namespaced seeder declaration. Done when the provided namespaced seeders run and the dependency is found without the "Could not find class" error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100