0

I keep getting this error

syntax error, unexpected '[' 

it is in the line 1 of the following code snippet:

Route.php

Route::get('api/test/{input}', [
    'before' => 'checkauth',
    "as"   => "test",
    "uses" => "TestController@show"
]);

what is wrong?

edi9999
  • 19,701
  • 13
  • 88
  • 127
user121196
  • 30,032
  • 57
  • 148
  • 198
  • 6
    The array literal syntax `[1,2,3,4,5]` as opposed to the longer language construct `array(1,2,3,4,5)` require PHP 5.4+. You cannot use it on 5.3.3. – Michael Berkowski Jan 27 '14 at 16:28
  • 1
    You need PHP/5.4 to use the [short array syntax](http://es1.php.net/manual/en/migration54.new-features.php). And you apparently [need PHP/5.3.7](http://laravel.com/docs/installation) to use Laravel. Your PHP is simply too old. – Álvaro González Jan 27 '14 at 16:30

2 Answers2

3

Change your array notation.

Route::get('api/test/{input}', array(
    'before' => 'checkauth',
    "as"   => "test",
    "uses" => "TestController@show"
));
Dave
  • 3,658
  • 1
  • 16
  • 9
0

As Michael Berkowski says, the use of the array notation with [ requires PHP 5.4+

From the Php array documentation

As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].

You should use the array(); notation:

Route::get('api/test/{input}', array(
    'before' => 'checkauth',
    "as"   => "test",
    "uses" => "TestController@show"
));
edi9999
  • 19,701
  • 13
  • 88
  • 127