有选择地继承实体的某些部分

I have many entities extending from one parent entity.

I want remove one or more column from only one of them, while keeping the inheritance.
I've tried to find a solution by mapping the parent entity as MappedSuperClass but it doesn't help.

Example :

<?php

/** @ORM\Entity */
class Base
{
    /** @ORMColumn(name="foo", type="string") */
    protected $foo;

    /** @ORMColumn(name="bar", type="string") */
    protected $bar

}

/**
 * @ORM\Entity
 */
class Child extends Base
{
    // How take only the Base::$bar column mapping 
    // and not the Base::$foo column mapping
}

The entire Inheritance mapping chapter of the doctrine documentation doesn't give me any alternative.

I need to really remove/exclude the columns from database, serialisation doesn't solve my problem.

Is there a way to achieve this ?

You can't selectively inherit parts of an entity class. It sounds like you need to refactor your Base class or perhaps introduce another abstract class depending on which properties your other classes share among each other.

i.e.

/**
 * @MappedSuperclass
 */
class Base
{
    /** @ORMColumn(name="foo", type="string") */
    private $foo;
}

/**
 * @MappedSuperclass
 */
class SomeOtherBase extends Base
{
    /** @ORMColumn(name="bar", type="string") */
    private $bar
}


/**
* @ORM\Entity
*/
class Child extends Base
{
    // How take only the Base::$bar column mapping 
    // and not the Base::$foo column mapping
}    

PHP does not allow to remove capabilities of a class through inheritance, it's only made and thought to handle the opposite.

see http://php.net/manual/en/language.oop5.inheritance.php

You can use traits and refactor inheritance :

<?php

trait BaseFooTrait
{
    /** @ORM\Column(name="foo", type="string") */
    protected $foo;

    // ... getter and setter
}

/**
 * @ORM\Entity
 */
class Base
{
    /** @ORM\Column(name="bar", type="string") */
    protected $bar;

    // ... getter and setter
}

/**
 * @ORM\Entity
 */
class FooBase extends Base
{
    use BaseFooTrait;
}

=> extending Base you have no foo.