简体   繁体   中英

Laravel's Artisan giving a parse error on Table Seeders

I have been facing me with a problem with php artisan db:seed when I run this command, it's returning this:

PHP Parse error:  parse error in /Users/Dev/Sites/Laravel_Proj/database/seeds/UserTableSeeder.php on line 6

 [Symfony\Component\Debug\Exception\FatalErrorException]  
  parse error  

In file UserTableSeeder.php you can clearly see there is nothing wrong with it, an if i save a new Seeder, it also prompts this error...

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
​
class UserTableSeeder extends Seeder {
​
    public function run()
    {
        DB::table('users')->delete();

        User::create(array(
            'name' => 'Test',
            'email' => 'test@tes.com',
            'password' => Hash::make('abc123'),
        ));

    }
}

I'm tired of seeing this error never happened to me, I have several projects working in this environment and everything works fine.

And look for this problem around the internet and it seems that I will not find a solution to this.

My version of PHP 5.5.14 (cli) (built: Sep September 2014 19:09:25) in laravel 5.0

Hope you can help me with this

I copied and pasted your code. You have two hidden characters (marked by â ):

use Illuminate\Database\Eloquent\Model;
â
class UserTableSeeder extends Seeder {
â
public function run()

Delete those lines and re-enter them. Your text editor should be able to view hidden characters so try changing the settings to see what I mean.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM