I’ve got Symfony 2 successfully installed and set up and have been following the documentation through.
I’m currently up to http://symfony.com/doc/2.0/book/doctrine.html
Everything is fine until I get to this line:
php app/console doctrine:generate:entities Acme/StoreBundle/Entity/Product
at which point I get the following error:
[RuntimeException]
The autoloader expected class "Acme\StoreBundle\Entity\Product" to be defined
in file "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Symf
ony\app/../src\Acme\StoreBundle\Entity\Product.php". The file was found but the
class was not in it, the class name or namespace probably has a typo.
This has happened to me on both Linux and Windows machines.
The contents of Product.php is as per the tutorial:
// src/Acme/StoreBundle/Entity/Product.php
namespace Acme\StoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="product")
*/
class Product
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $name;
/**
* @ORM\Column(type="decimal", scale=2)
*/
protected $price;
/**
* @ORM\Column(type="text")
*/
protected $description;
}
That message comes from DebugUniversalClassLoader.php:
So, the file must be there, and readable, otherwise the
findFileand therequirewouldn’t have worked. All this check is doing isrequire()ing the file and then using the standard PHP class_exists() to see if the class is now there.The only thing I can think of that could cause this message given those file contents: you’ve missed off the
<?phpat the start of the file. Now, I know this is going out on a bit of a limb, but I honestly can’t think of anything else that wouldn’t cause some other kind of error.