【问题标题】:DB:seed file for Laravel 4 working fine on local host, not working on Mediatemple gridserver?DB:Laravel 4 的种子文件在 localhost 上工作正常,在 Media Temple 网格服务器上不工作?
【发布时间】:2013-07-09 07:09:07
【问题描述】:

我有一个 Laravel 4 db:seed 文件,我想在 mediatemple 网格服务器上使用它。我能够使用工匠精细(php artisan migrate)运行迁移,并制作表格,但我无法为表格播种。此数据库播种在本地主机上运行良好。直到现在,我才在实时服务器上遇到任何问题。这是种子文件:

ArtistsTableSeeder.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' => 'Blah', 'city' => 'Blah', 'state' => 'blah', 'video_path' => 'youtube.com', 'image_path' => 'filepickerimage', 'soundcloud_profile' => 'https://soundcloud.com/', 'description' => '', 'created_at' => new DateTime, 'updated_at' => new DateTime]


        ];

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

}

它正在吐出这个错误:

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"syntax error, unexpected '['","file":"\/nfs\/c09\/h04\/mnt\/139243\/domains\/crowdsets.com\/html\/app\/database\/seeds\/ArtistsTableSeeder.php","linemichaelsutyak.com@n26:/home/139243/domains/crowdsets.com/html$ php artisan db:seed

它在抱怨开始数组的行:

$Artists = [

我不知道为什么会这样。一点帮助将不胜感激。谢谢!

【问题讨论】:

    标签: laravel laravel-4 seeding


    【解决方案1】:

    你得到的那个语法错误可能是由 PHP 5.4 (short array syntax) 中添加的一个特性引起的,所以我猜你的主机仍然运行 5.3.x。 您应该检查 mediatemple 网格服务器上的 PHP 版本,并在必要时进行更新。

    【讨论】:

    • 最坏结果,你可以在你的代码中简单地将[...] 的任何实例更改为array(...)。 Laravel 完全符合 php 5.3 - 它不使用任何 5.4 特定语法。
    • 在 mediatemple 上,它为我的域提供了使用 php 5.3.6 或 5.5.0 的选项。当我使用 5.5.0 时,我仍然得到相同的语法错误。
    • 我无法在 media Temple 上使用 gridserver 重新启动服务器..我仍然收到错误
    猜你喜欢
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 2013-10-01
    • 2011-03-17
    • 1970-01-01
    • 2016-10-28
    相关资源
    最近更新 更多