symfony make:entity crash on new project - php

Whenever I try to create an entity with bin/console make:entity, I get the following result:
php bin/console make:entity
Class name of the entity to create or update (e.g. FierceElephant):
> Video
In DebugClassLoader.php line 337:
Warning: include(/home/user/work/project1/vendor/composer/../../src/Entity/Video.php): failed to open stream: No such file or directory
This project is very new and there is very few code at the moment; It's the first entity I try to create in the project. I don't get why I get this since it's obvious that the file does not exist since I want to create it...
I haven't found similar problem on google. Maybe I forgot to activate a php extension?
Any idea?

Might need to composer dump-autoload if you've messed up and removed some classes by hand.

Related

I cannot remove entity class from symfony project without mistakes

I have the project with symfony5 and doctrine orm. I created entity in my project. And now I want to delete the entity from model. I deleted relashionships this entity and made migration. Then i deleted this entities from the project and made migration. But when I try to create new entity in php bin/console, i get next error:
Warning: include(C:\OpenServer\elearning\vendor\composer/../../src/Entity/Theme.php): failed to open stream: No such file or directory
What am i doing wrong?
I tried to make php bin/console d:s:u --force, but the error still appears
A little bit late but i just had the same problem.
Try running composer dump-autoload to generate a new classmap. Your ...\Entity\Theme.php probably still exists there.
After that, you should be able to run console commands again.

How to fix "new property name: Aborted" error when make:entity command finishes?

I would like to make Doctrine entity via Symfony 4 console command
php bin/console make:entity article
The command creates the entity and repository file but it does not allow me to add fields to the entity. Command ends up with an error:
New property name (press to stop adding fields): Aborted.
What does it mean? How can I solve it? PHP 7.4 Win 10 Doctrine 2
You should try with an uppercase. You should also check wether your database is associated correctly in your .env file with the right port.
Something like this:
DATABASE_URL="mysql://db_user:db_password#127.0.0.1:3306/db_name?serverVersion=5.7"

PHP Doctrine2 ORM "orm:generate:entities"

I want generate new "Banner" entity class:
vendor/bin/doctrine orm:generate:entities --generate-annotations="true" Entity/Banner
but I have this error:
[InvalidArgumentException] Entities destination directory
'Entity/Banner' does not exist.
The correct command is the next.
php vendor/bin/doctrine orm:generate-entities
You can see the docs in this page
But maybe your problem is other, like the directory does not exist.
Did you try like this?
vendor/bin/doctrine orm:generate:entities --generate-annotations="true" Banner
Use tab key to autocomplet the command, maybe that can help

Error when building models from propel schema

I got the errors below when running the command below. I already have my schema file generated from reverse engineering through propel.
Command
vendor/bin/propel build
Error 1
[RuntimeException]
Unable to write the "" directory
Error 2
[Symfony\Component\Filesystem\Exception\IOException]
Failed to create "": mkdir(): Invalid path.
Sounds like propel doesn't know where to put the files. Typing propel --help will give you command line options. There you find an option to specify an output folder.
propel model:build --output-dir C:\temp
(you'll have to specify a local OS X path instead of my Windows temp folder)
As I'm just trying out propel myself, the following post has lead me to the suspicion my propel.ext file is incomplete.
https://github.com/propelorm/Propel2/issues/694

Symfony2: Entity recreated after renamed

I've created a bundle Super, and created relative Entity "sin_table1.php" as "sin_table1" mysql table generation.
After an:
php app/console doctrine:generate:entities AcmeSuperBundle
and
php app/console doctrine:schema:update --force
Now i can see the full mysql table generated.
But if i rename sin_table1.php to another name as "mysql_schema.php", and i try to reload that commands, doctrine/symfony2 recreate "sin_table1.php" Entity file.
I tried to grep "sin_table1" key into symfony2 root project, but nothing found. Only caches, logs and the two Entitiy files(sin_table1.php & mysql_schema.php).
I've tried to clean cache, but nothing happened, always sin_table1.php recreated, and conflicts with mysql_schema.php because there is a double decaration of the same class.
How i can resolve it? where doctrine have sin_table1 entity configuration saved? why this happen?
i think that i've lost something reading manual....
Namefile: mysql_schema.php
namespace Acme\SuperBundle\Entity;`
use Doctrine\ORM\Mapping as ORM;`
/**`
* #ORM\Entity`
* #ORM\Table(name="sin_table1")`
*/`
class sin_table1`
{....`
In my new test, i've renamed clas as "sin_tablerrrrrrrrrr" and also #ORM\Table(name="sin_tablerrrrrrrrrr"....
and the result will be another file sin_tablerrrrrrrrrr.php created
If my supposition that namefile must be the same of the class, i could be sign as solved.
I've always set my class name identical to my php file name. I guess it's more a developer convention / best practice that an obligation.
Anyway, I've got the same problem few weeks ago and I saw that the command php app/console doctrine:schema:drop doesn't delete a renamed table. The table with the old name was not deleted by the command. So when I updated I had the both tables. Maybe it was your problem.

Categories