CodeIgniter Forums
Seeding -> Class not found - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Seeding -> Class not found (/thread-72794.html)



Seeding -> Class not found - mayo83 - 02-12-2019

Hello,

i used CI 3 before and i liked it a lot and now i want to write a inhouse Solution for my Company. So i thought it would be nice to start  with the new seeding possibilites.

But somehow my seed class cant be found. I even tried the example from the docs and created the SimpleSeeder Class:
PHP Code:
<?php namespace App\Database\Seeds;

class 
SimpleSeeder extends \CodeIgniter\Database\Seeder
{
 
       public function run()
 
       {
 
               $data = [
 
                       'username' => 'darth',
 
                       'email'    => 'darth@theempire.com'
 
               ];

 
               // Using Query Builder
 
               $this->db->table('users')->insert($data);
 
       }

The class is located in app/Database/Seeds/SimpleSeeder.php

And in the example Controller "Home.php" i called the seeder with:
PHP Code:
    public function index()
    {
 
               $seeder = \Config\Database::seeder();
 
               $seeder->call('SimpleSeeder');
        return 
view('welcome_message');
    } 

But every time i call the home Controller ill get the error Message that SimpleSeeder class could not be found. What am i missing here? And yes, i did the configuration for the Database in app/Config/Database.php


RE: Seeding -&gt; Class not found - mayo83 - 02-13-2019

Interesting twist: i tried the seeding at home on local xampp and there it worked flawless. But i tried an older Version of CI4. I cant tell u from when this version is, but the most obvious difference is that this version has an "application" directory and not the new "app" directory.

Ive got this feeling that this is a bug.


RE: Seeding -&gt; Class not found - mayo83 - 02-20-2019

Fix:

Instead of calling seeder like this:
PHP Code:
$seeder->call(SimpleSeeder'); 


Call it this way:

PHP Code:
$seeder->call('App\Database\Seeds\SimpleSeeder'); 



RE: Seeding -> Class not found - jasonzig - 03-04-2019

Does the path (output of the pwd unix command in terminal from inside your CI folder) have a tilde(~) in it?

There seems to be an issue with that: https://forum.codeigniter.com/thread-72950.html