Reputation: 3113
I need the command to generate a single entity from an existing database and I cannot get the command formatted correctly. I changed my setup to the DB in parameters.yml to look at the database in question and then I run:
php app/console doctrine:mapping:import AppBundle xml --filter="tbl_remote"
This keeps on complaining that some table that is not related to tbl_remote does not have a primary key. From the error message I can see that it is looking at the correct database but I need to create and entity for only one table.
From my understanding this will create an xml file and to get the entity I will run:
php app/console doctrine:generate:entities AppBundle:tbl_remote --path src/
Why will it not create the xml file?
Upvotes: 2
Views: 2153
Reputation: 3113
After finding that the --filter
does not do what I hoped, I scripted tbl_remote
and created it in my test database. I then changed parameters.yml
to look at the test database and after running: php app/console doctrine:mapping:import --filter="tbl_remote" AppBundle
i was greeted with: "Database does not have any mapping information."
This is not my day so I just ran: php app/console doctrine:mapping:import AppBundle
and removed the .orm.xml that I did not need.
I was then able to run: php app/console doctrine:generate:entities AppBundle
to generate the single entity!! Not what I wanted but not a complete loss.
Upvotes: 3
Reputation: 7586
to generate a single entity from the database I use this little sh
script:
#!/bin/bash
clear;
echo "####################################################################################################"
echo "# Generating the Doctrine files for a given entity, be carefull that the entities are CamelCased". #"
echo "####################################################################################################"
date
# Testing arguments
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: ./`basename $0` MyEntity"
exit $E_BADARGS
fi
php app/console doctrine:mapping:import CoreBundle annotation --filter=$1
php app/console doctrine:generate:entities Project\\Bundle\\CoreBundle\\Entity\\$1
echo " --> Done!"
date
Upvotes: 0