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

rickyspires's avatar

Can't solve syntax error in php artisan tinker.

Hello. I have an error in my syntax and I can not see what is wrong ?

$ php artisan tinker

\App\Tag::create(['name'=>'work']);

PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in /Users/rickyspires/Code/laravel5-demo-project/app/Tag.php on line 12

[Symfony\Component\Debug\Exception\FatalErrorException]
syntax error, unexpected '[', expecting ',' or ';'

The code comes from the Laracast video "Laravel5 fundamentals - 22-selecting tags"

Thanks Ricky

0 likes
4 replies
MartelliEnrico's avatar

@rickyspires the problem is not about php artisan tinker, it's about your Tag.php file, on line 12. Can you show us the class?

2 likes
rickyspires's avatar

Hello. Thank you for your reply. This is my Tag.php line 12.

    /*
* Fillable fields for a tag
*
* @var array
*/
protected $fillable [
    'name'
];
rickyspires's avatar

Found it :)

Missing a =

protected $fillable = [ 'name' ];

Thankyou :)

4 likes

Please or to participate in this conversation.