CodeIgniter Forums

Full Version: Seeding -> Class not found
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
Fix:

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


Call it this way:

PHP Code:
$seeder->call('App\Database\Seeds\SimpleSeeder'); 
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