Laravel 5.0 Faker 中的解析错误
Parse error in Faker for Laravel 5.0
I use "fzaninotto/faker": "^1.5"
<?php
use Faker\Factory as Faker; use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Gopro\Served;
class ServedTableSeeder extends Seeder {
public function run()
{
$faker = Faker::create();
foreach(range(1,20) as $index)
{
DB::table('server')->insert([
'name' => str_replace('.', '_', $faker->unique()->name),
'location' => $faker->city,
'happytyp_id' => $faker->biasedNumberBetween($min = 1, $max = 8, $function = 'sqrt'),
'operatingsystem' => $faker->randomElement($array = array ('Windows 8.1','Windows RT','Windows Server 2012','Windows 7', 'Windows Vista', 'Unix V7', 'AIX', 'A/UX', 'Solaris'),
'version' => strval($faker->numberBetween($min = 1, $max = 4))
]);
}
}
}
PHP 解析错误:
parse error in /Gopro/database/seeds/ServeTableSeeder.php on line 22
And I get the following error: [Symfony\Component\Debug\Exception\FatalErrorException]
parse error
我的模型和我的表格存在,我的 Databaseseeder.php 在上面:
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Gopro\Typ;
use Gopro\Served;
我已经完成了 composer dump-autoload。有人可以帮助我吗?
我也注意到
您有一个语法错误:
<?php
use Faker\Factory as Faker; use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Gopro\Served;
class ServedTableSeeder extends Seeder {
public function run()
{
$faker = Faker::create();
foreach(range(1,20) as $index)
{
DB::table('server')->insert([
'name' => str_replace('.', '_', $faker->unique()->name),
'location' => $faker->city,
'happytyp_id' => $faker->biasedNumberBetween($min = 1, $max = 8, $function = 'sqrt'),
'operatingsystem' => $faker->randomElement(array('Windows 8.1','Windows RT','Windows Server 2012','Windows 7', 'Windows Vista', 'Unix V7', 'AIX', 'A/UX', 'Solaris')),
// ^ removed redundant variable declaration You missed a closing parenthesis ^
'version' => strval($faker->numberBetween($min = 1, $max = 4))
]);
}
}
}
I use "fzaninotto/faker": "^1.5"
<?php
use Faker\Factory as Faker; use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Gopro\Served;
class ServedTableSeeder extends Seeder {
public function run()
{
$faker = Faker::create();
foreach(range(1,20) as $index)
{
DB::table('server')->insert([
'name' => str_replace('.', '_', $faker->unique()->name),
'location' => $faker->city,
'happytyp_id' => $faker->biasedNumberBetween($min = 1, $max = 8, $function = 'sqrt'),
'operatingsystem' => $faker->randomElement($array = array ('Windows 8.1','Windows RT','Windows Server 2012','Windows 7', 'Windows Vista', 'Unix V7', 'AIX', 'A/UX', 'Solaris'),
'version' => strval($faker->numberBetween($min = 1, $max = 4))
]);
}
}
}
PHP 解析错误:
parse error in /Gopro/database/seeds/ServeTableSeeder.php on line 22
And I get the following error: [Symfony\Component\Debug\Exception\FatalErrorException]
parse error
我的模型和我的表格存在,我的 Databaseseeder.php 在上面:
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Gopro\Typ;
use Gopro\Served;
我已经完成了 composer dump-autoload。有人可以帮助我吗?
我也注意到
您有一个语法错误:
<?php
use Faker\Factory as Faker; use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Gopro\Served;
class ServedTableSeeder extends Seeder {
public function run()
{
$faker = Faker::create();
foreach(range(1,20) as $index)
{
DB::table('server')->insert([
'name' => str_replace('.', '_', $faker->unique()->name),
'location' => $faker->city,
'happytyp_id' => $faker->biasedNumberBetween($min = 1, $max = 8, $function = 'sqrt'),
'operatingsystem' => $faker->randomElement(array('Windows 8.1','Windows RT','Windows Server 2012','Windows 7', 'Windows Vista', 'Unix V7', 'AIX', 'A/UX', 'Solaris')),
// ^ removed redundant variable declaration You missed a closing parenthesis ^
'version' => strval($faker->numberBetween($min = 1, $max = 4))
]);
}
}
}