초보자와 Symfony 2 (2.8. * 버전). Fixture와 faker로 샘플 데이터를 데이터베이스에로드하려고합니다. 나는 SRC/AppBundle/DataFixtures/ORM 디렉토리를 생성하고이 코드와 LoadPostData.php 파일을 거기에 넣어했습니다Symfony 2 - Fixture를로드 할 수 없습니다.
<?php
namespace AppBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistance\ObjectManager;
class LoadPostData implements FixtureInterface
{
public function load(ObjectManager $manager)
{
$faker = \Faker\Factory::create();
for ($i = 1; $i < 200; $i++) {
$post = new \AppBundle\Entity\Post();
$post->setTitle($faker->sentence(3));
$post->setLead($faker->text(300));
$post->setContent($faker->text(800));
$post->setCreatedAt($faker->dateTimeThisMonth);
$manager->persist($post);
}
$manager->flush();
}
}
하지만 명령 ": 비품 : PHP 응용 프로그램/콘솔 교리로드"를 쳤을 때 내
PHP Fatal error: Declaration of AppBundle\DataFixtures\ORM\LoadPostData::load(Doctrine\Common\Persistance\O
bjectManager $manager) must be compatible with Doctrine\Common\DataFixtures\FixtureInterface::load(Doctrine\Common\Persist
ence\ObjectManager $manager) in /Users/myMac/Desktop/symfony2/Blog/src/AppBundle/DataFixtures/ORM/
LoadPostData.php on line 10
Fatal error: Declaration of AppBundle\DataFixtures\ORM\LoadPostData::load(Doctrine\Common\Persistance\ObjectManager $manager) must be compatible with Doctrine\Common\DataFixtures\FixtureInterface::load(Doctrine\Common\Persistence\ObjectManager $manager) in /Users/myMac/Desktop/symfony2/Blog/src/AppBundle/DataFixtures/ORM/LoadPostData.php on line 10
내가 잘못 여기서 할 일을
(라인 10 LoadPostData 클래스의 선언은) : 터미널이 오류를 얻을? 튜토리얼 단계를 따라 단계별로 실종 된 것이 무엇인지 모릅니다. 미리 감사드립니다! 인
Fatal error: Declaration of AppBundle\DataFixtures\ORM\LoadPostData::load(Doctrine\Common\Persistance\ObjectManager $manager) must be compatible with Doctrine\Common\DataFixtures\FixtureInterface::load(Doctrine\Common\Persistence\ObjectManager $manager) in /Users/myMac/Desktop/symfony2/Blog/src/AppBundle/DataFixtures/ORM/LoadPostData.php on line 10
2 개 개의 선언 :
::load(Doctrine\Common\Persistance\ObjectManager $manager)
::load(Doctrine\Common\Persistence\ObjectManager $manager)
당신은 당신의
use
성명에서
Persistence
철자를 잘못하여 오류 메시지에서 함수 호출을 잡아
'load' 함수는 public이어야합니다. – ccKep
오른쪽. 나는 그것을 고정했지만 여전히 같은 오류가 발생한다. – ampher911
"Persistence"라는 오타가있다. "Persistence"라고 불린다. Doctrine \ Common \ Persistence \ ObjectManager; – ccKep