0

我有一些使用使用约定的数组的种子文件:

Array = [  ]; 

该数组使用方括号而不是圆括号。

我已经使用 phpinfo.php 文件检查了我的 php 版本,它正在读取:PHP Version 5.5.0

当我尝试在终端中运行 php artisan db:seed 时,出现以下错误:

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}}

这在我的本地主机上运行良好,所以我不知道出了什么问题。谢谢您的帮助!

编辑(这里是 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);
    }

}

回答编辑:对于其他有问题的人,在命令行中我必须使用 php-latest artisan db:seed。这确保我使用了最新版本的 php。

4

1 回答 1

0

与您的 HTTP 服务器相比,命令行指向不同的 PHP 文件。

您需要与您的服务器主机交谈并告诉他们您的命令行 PHP 版本是 5.3.26,但您需要它至少为 5.4。是否可以更改取决于他们。

如果您无法更改命令行 PHP 版本 - 您可以使用此包通过 Web 执行工匠命令:

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

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

或者另一个选项只是将您的数组从 [] 更改为 array() - 并让它使用 5.3

于 2013-07-17T02:26:37.503 回答