Hi,
I try to learn Symfony with a video tutorial and i have an issue when i try to use this in terminal:
php bin/console doctrine:database:create
I have this message:
"Too many arguments, expected arguments "command"."
How can I connect to the mysql local website ? What's the address ?
Edit : When i use "root" instead of "whyj06" username i have this
You should execute only php bin/console doctrine:database:create without your database name.
Your database name is configured in your config file.
Please check you .env file where you specify DATABASE_URL variable and adjust it to the schema.
DATABASE_URL=mysql://db_user:db_password#127.0.0.1:3306/db_name
if your user name is whyj06 and there is no password, modify your url to:
DATABASE_URL=mysql://whyj06#127.0.0.1:3306/demo
after that try to running doctrine:database:create without any additional arguments:
php bin/console doctrine:database:create
Please notice that if your database was already created this command will return error. To avoid that you can add --if-not-exists argument to create database only if it does not exist yet.
php bin/console doctrine:database:create --if-not-exists
Related
when i run this command php bin/console make:reset-password i get a problem from In AbstractManagerRegistry.php line 158:Doctrine ORM Manager named "" does not exist.
php bin/console make:reset-password
from In AbstractManagerRegistry.php line 158:Doctrine ORM Manager named "" does not exist.
i used mongodb and symfony 5
i tried creating a new data base using the command:
$ bin/console doctrine:database:create
and I got the following errors:
In ExceptionConverter.php line 91: An exception occurred in the
driver: could not find driver
In Exception.php line 26: could not find driver
In Driver.php line 28: could not find driver
also i tried modifying the database url from:
# DATABASE_URL="mysql://db_user:db_password#127.0.0.1:3306/db_name?serverVersion=5.7"
to
# DATABASE_URL="mysql://root:#127.0.0.1:3306/SMF?serverVersion=5.7"
I'm using xampp server.
Make sure You have installed all drivers in that machine.
As far as I remember it is: php-pdo and php-pdo_mysql - depending on Your OS.
You need to have a mysql client to make such database.
Basically run this command in Your console:
symfony check:requirements
It will show You what package You are missing to run a Symfony app.
Don't forget to match your MySQL Server version with DNS:
DATABASE_URL="mysql://root:#127.0.0.1:3306/SMF?serverVersion=X.Y"
And lastly, Ouss Ma L'aire Bien mentions, uncomment the DATABASE_URL You want to use and comment out all others.
in your case you should delete the "#"
and if there are other lines staring with DATABASE_URL in your .env file just put "#" in the begining
in other cases, just try your windows cmd
After the database has moved to a different server and a different schema name, I updated the .env file and when entering php artisan config:cache it writes the error message
"SQLSTATE[HY000] [1049] Unknown database 'OLD_DB'" - (OLD_DB refers to
the database name before the change).
I don't know why it still looks for the old name as if I didn't update the .env file. I also tried to write php artisan cache:clear and even just php artisan alone and received this error. Also composer update did not help - in the end it tries to run #php artisan package:discover.
Eventually I managed to solve the problem by clearing the cache:
rm -f bootstrap/cache/*
This allowed me to (finally) run:
php artisan config:clear
and the new configuration was on the air.
So .. i create two entities from console
Then i type php bin/console doctrine:schema:update and get "No metadata Classes to process. (i already tried everything who found)
Then try to debug with php bin/console doctrine:mapping:info and get this:
Any ideas?
parameters.yml:
config.yml:
I create an Entity by using commandline php app/console generate:doctrine:entity.
Now I want to delete that Entity(yml, schema..). I delete Doctrine yml file and Entity directory but when I use command line doctrine:schemal:create that always create Table which name = that Entity in Database?
To delete a generated entity, please delete the yml that contains the schema, which is located in BundleName/Resources/config/doctrine/entityName.orm.yml file. Then, delete the entityName.php in BundleName/Entities/ and clear the cache using
php app/console cache:clear
after removing the entity and clearing the cache try this command : doctrine:schema:update --force --complete