3

I'm trying to apply this tutorial to my project, but I don't get it working. Everytime I try to update my schema i get an error: Fatal error: Cannot redeclare class Rueckgrat\App\Models\ProjectSetting in.....

I have 2 files. The first one is ProjectSetting.php

namespace Rueckgrat\App\Models;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity()
 * @ORM\Table(name="project_setting")
 * @ORM\HasLifecycleCallbacks()
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="is_production", type="integer")
 * @ORM\DiscriminatorMap({"0" = "ProjectCalculation", "1" = "ProjectSetting"})
 */
class ProjectSetting
{
// More code here
}

The second one is ProjectCalculation.php

namespace Rueckgrat\App\Models;
use Doctrine\ORM\Mapping AS ORM;
/**
 * @ORM\Entity
 */
class ProjectCalculation extends \Rueckgrat\App\Models\ProjectSetting
{      
....
}

Any help or hint appreciated.

Update:

Full error message: Fatal error: Cannot redeclare class Rueckgrat\App\Models\ProjectSetting in /Applications/MAMP/htdocs/Rueckgrat/app/models/ProjectSetting.php on line 17

I just tried the example from the Doctrine documentation, just splited in two entity files and it is not working. Then i copied the ProjectCalculation class in the file of ProjectSetting and it is working.

Update 2:

I can't update my Schema, but it is saving the correct discriminator to the project_setting table, when i save an ProjectCalculation Entity.

Abenil
  • 1,048
  • 3
  • 12
  • 26
  • The error message is perhaps very important, please do not truncate it. – greg0ire Nov 02 '11 at 14:37
  • Fatal error: Cannot redeclare class Rueckgrat\App\Models\ProjectSetting in /Applications/MAMP/htdocs/Rueckgrat/app/models/ProjectSetting.php on line 17 – Abenil Nov 02 '11 at 14:54
  • can you find `class ProjectSetting` in any other file? The second option in your DiscriminatorMap declaration looks suspicious. – greg0ire Nov 02 '11 at 14:57
  • no, there is no double declaration of the ProjectSetting Class. What do you mean with suspicious? Its like in the documentation, or?! – Abenil Nov 02 '11 at 15:00
  • My bad, I thought there should be no option for the mother class, but obviously, you can do that. – greg0ire Nov 02 '11 at 15:04
  • Are you sure the ProjectCalculation class definition is correct: class ProjectCalculation extends \Rueckgrat\App\Models\ProjectSetting. Shouldn't it simply be class ProjectCalculation extends ProjectSetting. Of course previus to this you should type use \Rueckgrat\App\Models\ProjectSetting; – ab_dev86 Nov 02 '11 at 16:03
  • it doesn't matter, how you declare the class. and i get the same error, when i do it like you said. – Abenil Nov 02 '11 at 16:21

1 Answers1

1

This can be the problem with PHP accelerator on your machine. Please turn off APC or XCache (whatever you have there), restart PHP/Apache and try again.

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
  • thanks i will try that, but i found out that the cli script caused much trouble. if i generate my entities, proxies and database via php it is working. only when i do it via CLI i get those errors. – Abenil Nov 18 '11 at 14:01