0

I have a few seed files that make use of arrays that use the convention:

Array = [  ]; 

The array uses brackets instead of parentheses.

I have checked my php version using a phpinfo.php file, and it is reading: PHP Version 5.5.0

When I try to run php artisan db:seed in the terminal, I get the following error:

php artisan db:seed

    {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"syntax error, unexpected '['","file":"\/nfs\/c09\/h04\/mnt\/139243\/domains\/*********.com\/app\/database\/seeds\/ArtistsTableSeeder.php","line":14}}

This has worked fine on my localhost, so I don't know what is going wrong. Thank you for your help!

EDIT (Here is ArtistsTableSeeder.php):

<?php

class ArtistsTableSeeder extends Seeder {

    public function run()
    {
        // Uncomment the below to wipe the table clean before populating
        // DB::table('artists')->delete();

        $artists = array(

        );

        $Artists = [
            ['stage_name' => 'Bob', 'city' => 'San Francisco', 'state' => 'CA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime],
            ['stage_name' => 'Joe', 'city' => 'San Francisco', 'state' => 'CA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime],
            ['stage_name' => 'George', 'city' => 'San Francisco', 'state' => 'CA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime],
            ['stage_name' => 'Greg', 'city' => 'Seattle', 'state' => 'WA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime],
            ['stage_name' => 'Leo', 'city' => 'San Francisco', 'state' => 'CA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime],
            ['stage_name' => 'Nuck', 'city' => 'San Francisco', 'state' => 'CA', 'video_path' => 'http://www.youtube.com', 'image_path' => 'https://www.filepicker.io', 'soundcloud_profile' => 'https://soundcloud.com', 'created_at' => new DateTime, 'updated_at' => new DateTime]

        ];

        // Uncomment the below to run the seeder
        DB::table('artists')->insert($Artists);
    }

}

ANSWER EDIT: For others having issues, in the command line I had to use php-latest artisan db:seed. This ensured I used the latest version of php.

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
user1072337
  • 12,615
  • 37
  • 116
  • 195
  • can you please post your full ArtistsTableSeeder.php? – Laurence Jul 17 '13 at 01:18
  • yes, I will add it as an edit right now. EDIT: Added to my original question. – user1072337 Jul 17 '13 at 01:43
  • what happens if you add dd(phpmyinfo()) to your artisan.php file - what version is output from THAT? – Laurence Jul 17 '13 at 02:09
  • It output this error: {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to undefined function phpmyinfo()","file":"\/nfs\/c09\/h04\/mnt\/139243\/domains\/*******.com\/artisan","line":61}} – user1072337 Jul 17 '13 at 02:18
  • sorry - dd(phpinfo()). Even better just do this: dd(phpversion()); – Laurence Jul 17 '13 at 02:20
  • Ok, this worked. And it output: string(6) "5.3.26". I do not know why it is running this version of PHP when I changed it on the server to be php 5.5.0 and my phpinfo.php file is reading php 5.5.0 – user1072337 Jul 17 '13 at 02:22
  • the command line is probably pointing to a different PHP file compared to your HTTP server. You'll need to talk to your server host. – Laurence Jul 17 '13 at 02:24
  • ok, what do I tell them to change? – user1072337 Jul 17 '13 at 02:25

1 Answers1

0

The command line is pointing to a different PHP file compared to your HTTP server.

You'll need to talk to your server host and tell them your command line PHP version is 5.3.26 but you need it to be at least 5.4. Its up to them if they can change it or not.

If you are unable to change your command line PHP version - you could possibility do the artisan commands via the web using this package:

https://github.com/jn-Jones/web-artisan

http://forums.laravel.io/viewtopic.php?id=10334

Or the other option is just change your array from [] to array() - and let it use 5.3

Laurence
  • 58,936
  • 21
  • 171
  • 212
  • My host providers was able to run it by using the command: php-latest artisan db:seed. However, when I run the same command in the same directory, I get: -bash: php-latest: command not found – user1072337 Jul 17 '13 at 02:48
  • you'll need to liaise directly with your host provider about it - there is not much more support we can give you - it is specific to their server and their environment. sorry. But I have given you two other options in my answer if you cannot fix the problem with them – Laurence Jul 17 '13 at 02:50