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.
Related
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"
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.
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
I'm working through Laracasts Laravel 5 Fundamentals however when coming to run a migration again I found that I had duplicate migrations at which point I figured - I should likely delete that. So I did... then began my issues.
When I attempt to load a migration now I get the following error:
[ErrorException]
include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to
open stream: No such file or directory
However when I checked my database (Note that I have deleted and recreated it in order to combat my issue) and there are only two records in the mirgations table:
vagrant#homestead:~/Code/Laravel$ sqlite3 storage/database.sqlite
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
sqlite> select * from migrations;
2014_10_12_000000_create_users_table|1
2014_10_12_100000_create_password_resets_table|1
sqlite>
Any help would be appreciated, if I'm being a moron and missing something obvious please feel free to point that out too.
Thanks!
The first error:
[ErrorException]
include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to
open stream: No such file or directory
should be fixed executing composer dump-autoload.
About the second one: "However when I checked my database (Note that I have deleted and recreated it in order to combat my issue) and there are only two records in the mirgations table:"
As you said that you have recreated it, something went wrong because there is no migrations table, delete it and build it again
rm storage/database.sqlite
touch storage/database.sqlite
php artisan migrate:install
php artisan migrate
Please try, this one helped me to solve my problem
composer dump-autoload
Thanks
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.