Reputation: 322
I tried generate getters and setters in Symfony 3.0.1
when i run command
php bin/console doctrine:generate:entities VendorName/MyBundle/EntityName
i have error
Namespace "VendorName\MyBundle\EntityName" does not contain any mapped entities.
where is the mistake?
Edit-1: First generate entity with YAML format
Edit-2: I tried generate getters and setters for vendor bundle
Also i try with command php bin/console doctrine:generate:entities VendorNameMyBundle:EntityName and have another error:
Can't find base path for "VendorName\MyBundle\Entity\EntityName" (path: "/home/site/vendor/vendorname/mybundle/Entity", destination: "/home/site/vendor/vendorname/mybundle/Entity").
Upvotes: 4
Views: 4291
Reputation: 330
Symfony 3.22 with src/AppBundle/Entity/User.php
if you add new field using ORM
**/**
* @ORM\Column(name="last_login", type="datetimetz")
*/
private $lastLogin;**
just use
use php bin/console doctrine:generate:entities AppBundle
it will check all your Entities r and update getters and setters
then use
php bin/console doctrine:schema:update to update your database
use
php bin/console doctrine:schema:update --force in PROD enviroment
Upvotes: -1
Reputation: 5542
You have mistake in command, you trying to generate entities but you provide class name for one entity. Try the following for all entities:
php bin/console doctrine:generate:entities VendorName/MyBundle
or if you want just one entity:
php bin/console doctrine:generate:entity VendorName/MyBundle/EntityName
Upvotes: 0
Reputation: 2254
As John Pancoast points out in his answer to a different question:
Doctrine does not support PSR-4 when doing anything with code generation. It has to do with how they map class namespaces to filesystem paths and how PSR-4 allows class/namespace paths that don't directly map to the filesystem.
To clarify what exactly is needed to resolve the error message; You have to edit your bundle's composer.json
file, and also change the bundle's folder structure.
in composer.json
change psr-4
to psr-0
:
"autoload": {
"psr-4": { "Acme\\Bundle\\AwesomeBundle\\": "" }
},
to:
"autoload": {
"psr-0": { "Acme\\Bundle\\AwesomeBundle\\": "" }
},
Change bundle's folder structure from:
vendor
+--acme
+--awesome-bundle
|--Controller
|--Entity
to:
vendor
+--acme
+--awesome-bundle
+--Acme
+--Bundle
+--AwesomeBundle
|--Controller
|--Entity
The following command will no longer throw an exception:
bin/console doctrine:generate:entities AwesomeBundle
Upvotes: 2