Welcome Guest, Not a member yet? Register   Sign In
Database seeder with namespaces
#3

(04-21-2022, 12:30 AM)XMadMax Wrote: Hello, I developed a CI4 Modular structure, all works Ok, but I have a problem with Seeder.

Migrations (php spark migrate) works ok, because the migrate program uses namespaces, but "php spark db: seed" only uses filesPath config, instead of those path defined in command line (php spark db: seed Users/MySeeder.php)

As suggestion, system/Comands/Database/Seed.php would share $params with Seeder.php to be able to use namespaces.

If, as the example proposed, $params contains 'Users/Database/Seeds/MySeeder.php', in the constructor, $this->seedPath would to be set properly if first part of route is a defined in autoload.php:$psr4

Thanks,

Xavier

Here is an example:

Code:
public $psr4 = [
        'MyNameSpace'         => APPPATH . 'ThirdParty\MyPackag',
    ];

Code:
php spark db:seed MyNameSpace\Database\Seeds\UrgenciesSampel

NOTE:
UrgenciesSampel IS HERE :

Code:
app\ThirdParty\MyPackag\Database\Seeds\UrgenciesSampel.php
Reply


Messages In This Thread
Database seeder with namespaces - by XMadMax - 04-21-2022, 12:30 AM
RE: Database seeder with namespaces - by kenjis - 04-21-2022, 01:26 AM
RE: Database seeder with namespaces - by datamweb - 04-21-2022, 02:38 AM
RE: Database seeder with namespaces - by XMadMax - 05-11-2022, 08:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB