phinx icon indicating copy to clipboard operation
phinx copied to clipboard

getDependencies() doesn't work nicely with namespaced seeders

Open dfsoeten opened this issue 6 years ago • 1 comments

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?

dfsoeten avatar Feb 08 '19 14:02 dfsoeten

Maybe someone can help here?

dereuromark avatar Apr 11 '20 06:04 dereuromark