Laravel 5: DB Seed class not found

I have this DatabaseSeeder.php:

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;



    class DatabaseSeeder extends Seeder {

        /**
         * Run the database seeds.
         *
         * @return void
         */
        public function run()
        {
            Model::unguard();

            $this->call('MemberInvitationSeeder');
        }
    }

I have this MemberInvitationSeeder.php file, sibling for the DatabaseSeeder.php file

<?php

use Illuminate\Database\Seeder;
use App\MemberInvitation;

    class MemberInvitationSeeder extends Seeder {

        public function run()
        {
            MemberInvitation::truncate();

            MemberInvitation::create( [
                'id' => 'BlahBlah' ,//com_create_guid(),
                'partner_id' => 1,
                'fisrt_name' => 'Thats',
                'last_name' => 'Me',
                'email' => 'me@mymail.com',
                'mobile_phone' => '444-342-4234',
                'created_at' => new DateTime
            ] );

        }
    }

Now i'm calling

php artisan db:seed

and I get:

[ReflectionException]                        
  Class MemberInvitationSeeder does not exist

I tried everything I could find, including linker-autoload. but to no avail. What am I doing wrong?

+4
source share
2 answers

I think now I know the reason.

The new MemberInvitationSeeder class was not in startup classes in the composer.json file.

This was not because I added this class manually.

Now, if I add classes again, what should I use to automatically load my class into the autoloader?

-1
source

Step One - Generate Seed:

php artisan make:seed MemberInvitationSeeder

. DatabaseSeeder.php :

$this->call(MemberInvitationSeeder::class);

:

composer dump-autoload

:

php artisan db:seed


, composer.json , "":

"classmap": [
    "database"
],
+13

All Articles