Artisan db:seed (Laravel 4) receiving error on mediatemple gridserver even though php version is 5.5.0

StackOverflow https://stackoverflow.com/questions/17688828

Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top