mrsharko
mrsharko

Reputation: 295

symfony The file was found but the class was not in it

when I run this command on my terminal

php app/console doctrine:schema:validate

I get this error

  The autoloader expected class "tuto\testBundle\Entity\product" to be defined in file "../src/tuto/testBundle/Entity/product.php". The file was found but the class was not in it, the class name or names  
  pace probably has a typo.                                                                                 

I using symfony 2.8 and my code like the example page so what's the wrong ?

the product.php file code

<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;


/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */
class product 
{


  /** 
  *@ORM\Column(type="integer")
  *@ORM\Id
  *@ORM\GeneratedValue(strategy="AUTO")  
  */


  private $id;
  /** @ORM\Column(length=140) */




  public function getUserId(){
    return $this->UserId;
  }
  public function setUserId($id){
    return $this->UserId=$id;
  }
}

and the product.orm.yml file

AppBundle\Entity\product:
  type: entity
  table: product
  id:
    id:
      type: integer
      generator:
        strategy: AUTO

Upvotes: 0

Views: 421

Answers (1)

ehymel
ehymel

Reputation: 1391

You need to capitalize your class name:

class Product

See symfony coding standards here. Specifically, PSR-1 specifies using StudlyCaps for class names.

Upvotes: 5

Related Questions