Welcome Guest, Not a member yet? Register   Sign In
Seeding -> Class not found
#1

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'    => '[email protected]'
 
               ];

 
               // 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
Reply
#2

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.
Reply
#3

Fix:

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


Call it this way:

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

(This post was last modified: 03-05-2019, 03:48 AM by jasonzig. Edit Reason: did more research )

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

(Using CodeIgniter since 1.x)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB