Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jean's avatar
Level 1

php artisan db:seed

When i run command php artisan db:seed in Laravel 5 then occurs error how to remove this Plz Help me..

exception 'ReflectionException' with message 'Class ArticlesTableSeeder does not exist' in C:\xampp\htdocs\laravel\storage\framework\compiled.php:1026 Stack trace: #0 C:\xampp\htdocs\laravel\storage\framework\compiled.php(1026): ReflectionClass ->__construct('ArticlesTableSe...') #1 C:\xampp\htdocs\laravel\storage\framework\compiled.php(977): Illuminate\Conta iner\Container->build('ArticlesTableSe...', Array) #2 C:\xampp\htdocs\laravel\storage\framework\compiled.php(1476): Illuminate\Cont ainer\Container->make('ArticlesTableSe...', Array) #3 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Seed er.php(55): Illuminate\Foundation\Application->make('ArticlesTableSe...') #4 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Seed er.php(37): Illuminate\Database\Seeder->resolve('ArticlesTableSe...') #5 C:\xampp\htdocs\laravel\database\seeds\DatabaseSeeder.php(18): Illuminate\Dat abase\Seeder->call('ArticlesTableSe...') #6 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Cons ole\SeedCommand.php(57): DatabaseSeeder->run() #7 [internal function]: Illuminate\Database\Console\SeedCommand->fire() #8 C:\xampp\htdocs\laravel\storage\framework\compiled.php(922): call_user_func_a rray(Array, Array) #9 C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Console\Comma nd.php(115): Illuminate\Container\Container->call(Array) #10 C:\xampp\htdocs\laravel\vendor\symfony\console\Symfony\Component\Console\Com mand\Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Compon ent\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOut

0 likes
24 replies
bobbybouwmann's avatar

Can you show your DatabaseSeeder.php and your ArticlesTableSeeder.php?

Jean's avatar
Level 1

yes ArticlesTableSeeder.php

use Illuminate\Database\Seeder; use DB;

class ArticlesTableSeeder extends Seeder{

    public function run(){

        DB::table('articles')->delete();

        DB::table('articles')->insert(array(

            array(

                    'id'=>1,

                    'topic_name'=>'intro Wordpress',


                    'description'=>'Wordpress is content management system'

                )
            ));
    }
}

And

DatabaseSeeder.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('UserTableSeeder');
    $this->call('ArticlesTableSeeder');
}

}

zefman's avatar

try 'composer dump-autoload" and "php artisan clear-compiled"

4 likes
Jean's avatar
Level 1

@zefman Not try 'composer dump-autoload" i am use local server xampp..

bobbybouwmann's avatar

You can still use composer if you work on a local environment..?

Jean's avatar
Level 1

I don't use use composer how to use this..I am simple use local environment mysql

MikeHopley's avatar

Laravel doesn't know how to find that class.

You need to set up a class auto-loader. Composer includes an auto-loader, and that's what people normally use. That's why composer dumpautoload was suggested.

Can you find a file called composer.json in your laravel folder?

rawfan's avatar

@Jean I suggest you start at the beginnings on how to use Laravel. See the Quickstart or the Laravel 5 Essentials series here on Laracasts. If you need a terminal in Windows, use git-bash which comes with the Windows version of git.

Jean's avatar
Level 1

@rawfan I have learn basic of laravel.. But in laravel 5 .i did not understand.when i run command php artisan:db seed then errors occurs.but in laravel 4 it's work correctly.but in Laravel 5 error produced plz tell me how to solve..

rawfan's avatar

@Jean The basics are, that you need to use composer. Saying that you don't use composer because you use xampp sounded to me as if you got something fundamentally wrong. How do you install dependencies? How should Laravel know about dependencies (if not the composer autoloader). If these things seem new or strange to you, I really urge you to do yourself a favor and start at the beginning.

Please try to follow the Laravel 5 Essentials series which handles all this stuff. It is currently free to watch.

1 like
Jean's avatar
Level 1

@rawfan.. But error is occur When C:\xampp\htdocs\laravel>php artisan:db seed

Could not open input file: artisan:db

rawfan's avatar

@Jean We already told you a solution to your problem. Laravel can't find it's classes because they are not being autoloaded. Start at the beginning. Learn how things actually work. I have no more comments for you, sorry.

MikeHopley's avatar

In your composer.json, there should be a block called autoload. Mine looks like this:

"autoload": {
        "classmap": [
            "app/controllers",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/tests/MailTestCase.php",
            "app/tests/_helpers/"
        ],
        "files": [
            "app/BBapp/legacy/functions.php"
        ],
        "psr-0": {
            "BBapp\\": "app"
        }
    },

This is where you tell Laravel how to find the classes in your application. Whenever you change this, you need to run composer dumpautoload.

My autoload block shows three different ways of autoloading classes:

The classmap block lets you list individual folders or classes that you want to be autoloaded. A folder will not be scanned recursively -- i.e. you would need to list a subfolder too if you wanted its classes to be loaded.

The files block lets you load functions from a file. This is good for global functions that do not really belong in a class.

The psr-0 block is the really good bit. This will recursively scan the folder for classes and load them. It expects you to namespace your classes in accordance with the PSR standard. You can choose which PSR standard to follow.

In my case I am on Laravel 4.2 and using PSR-0. Things have changed a bit in Laravel 5, but it's much the same idea.

outman's avatar

u need do this on top of your ArticlesTableSeeder.php :

use \App\Articles;

d0ct0r4r6a's avatar

I am using Laravel 5.4 AND Composer 1.4 . I may miss some details about autoloading, etc. but my suggestion is based on what I found in my Laravel 5.4 projects.

In your DatabaseSeeder.php , change the arguments of your call() method as follows:

public function run()
{
    Model::unguard();

    // $this->call('UserTableSeeder');
    $this->call('ArticlesTableSeeder'); // from this way
    $this->call(ArticlesTableSeeder::class); // to this

}

Just sharing the differences, don't know if it matters :D

kishanbhatt's avatar

You have to use this at starting,

use App\User;

in both files i.e. DatabaseSeeder.php and UserTableSeeder.php

Snapey's avatar

Hi @kishanbhatt

There are lots of current questions that need answers rather than one from over 2 years ago!

Please or to participate in this conversation.