You're not missing :mapping
as there is no mapping command within the Doctrine Tools. The Doctrine Symfony Bundle probaly made its own command and forwards it to another command within the Doctrine Tools. (Some one with some Symfony knowledge able to confirm?). As for ZF using php /vendor/bin/doctrine-module list
lists all the Doctrine Tool commands. You should take a look at the Doctrine ORM Tools.
As described within the documentation you should probaly use the Reverse engineering. As I did understood that you want to create models/entities from an existing database.
But before reverse engineering your database to models you should consider the following as stated by Doctrine:
Reverse Engineering is a one-time process that can get you started with a project. Converting an existing database schema into mapping files only detects about 70-80% of the necessary mapping information. Additionally the detection from an existing database cannot detect inverse associations, inheritance types, entities with foreign keys as primary keys and many of the semantical operations on associations such as cascade.
And notice the following as this might be important as you have to check what has been created and correct it when needed.
Reverse Engineering is not always working perfectly depending on special cases. It will only detect Many-To-One relations (even if they are One-To-One) and will try to create entities from Many-To-Many tables. It also has problems with naming of foreign keys that have multiple column names. Any Reverse Engineered Database-Schema needs considerable manual work to become a useful domain model.
And don't use Symfony 3 documentation to help you out with Zend Framework integration of Doctrine, as both got their own ways (Bundles vs Modules). Sure some things within the Symfony Bundle or Zend Module are matching but that is just based on the tools provided by Doctrine itsself.
Edited due to comments
As stated in the comments, it is not really clear which command replaces the Symfony command: $ php bin/console doctrine:mapping:import --force AcmeBlogBundle xml
. Within your ZF2/3 application you don't have this function to generate the mapping for you instantly within the Doctrine (ORM) Module. As in Symfony you can specify the Bundle which you want to generate the entities for. This is a specific thing build within Symfony. To mimic this you've do it yourself within a Zend Framework application.
Within your ZF application you've to create your own task to do so, so you've to create this job on something where you've got access to your EntityManager.
/** @var \Doctrine\Orm\EntityManager $em */
$em = $this->getEntityManager();
$em->getConfiguration()->setMetadataDriverImpl(
new \Doctrine\ORM\Mapping\Driver\DatabaseDriver(
$em->getConnection()->getSchemaManager()
)
);
$cmf = new \Doctrine\Orm\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$metadata = $cmf->getAllMetadata();
$cme = new \Doctrine\Orm\Tools\Export\ClassMetadataExporter();
//$_exporterDrivers = array(
// 'xml' => 'Doctrine\ORM\Tools\Export\Driver\XmlExporter',
// 'yaml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter',
// 'yml' => 'Doctrine\ORM\Tools\Export\Driver\YamlExporter',
// 'php' => 'Doctrine\ORM\Tools\Export\Driver\PhpExporter',
// 'annotation' => 'Doctrine\ORM\Tools\Export\Driver\AnnotationExporter'
//);
$exporter = $cme->getExporter('xml', '/path/to/export/xml');
$exporter->setMetadata($metadata);
$exporter->export();
For example in your Module.php
in your Application module. Add this method: public function onBootstrap(MvcEvent $event)
class Module
{
public function onBootstrap(\Zend\Mvc\MvcEvent $event)
{
$entityManager = $event->getApplication()->getServiceManager()->get('doctrine.entitymanager.orm_default');
// code block above
// remove this code when export is done
}
}
Now that we've got your metadata within the XML file or the file type you specified, you can use the following command to create the entities:
$ php doctrine orm:convert-mapping --from-database xml /path/to/mapping-path-converted-to-xml
Doctrine-module users:
$ php /vendor/bin/doctrine-module orm:convert-mapping --from-database xml /path/to/mapping-path-converted-to-xml