doctrine 2 with CodeIgniter 2 No Metadata classes

2019-04-14 15:46发布

I use CodeIgniter 2 with doctrine 2 and this is the project that I am working in

https://github.com/wildlyinaccurate/CodeIgniter-2-with-Doctrine-2

I need to generate Entity classes from existing Database

so I configured the Doctrine to be in development mode and I set the Database on the CodeIgniter

after that I write this command

php doctrine orm:convert-mapping --from-database annotation models/generated

the classes generated correctly from database but without any method,after that I write this command for generating entities

php doctrine orm:generate-entities --regenerate-entities="1" models/generated

but I find this error "No Metadata classes to process"

Thanks.

4条回答
Viruses.
2楼-- · 2019-04-14 16:09

In Doctrine.php in libraries folder add these lines, to load the driver:

$driver = new \Doctrine\ORM\Mapping\Driver\PHPDriver(APPPATH.'models/Mappings');
$config->setMetadataDriverImpl($driver);

Create your Mapping files. And generate entities:

php cli-doctrine.php orm:generate-entities models --generate-annotations=true

Now you can create tables in your db:

php cli-doctrine.php orm:schema-tool:create
查看更多
贼婆χ
3楼-- · 2019-04-14 16:09

Here is correct line of code try now:

php doctrine orm:generate-entities --generate-annotations=true models/generated
查看更多
ら.Afraid
4楼-- · 2019-04-14 16:11

Most of doctrine documentation and tutorials are not correct. You should use this command:

php doctrine orm:generate:entities --generate-annotations=true models/generated
查看更多
等我变得足够好
5楼-- · 2019-04-14 16:28

In the entity files generated, you neet do delete "use Doctrine\ORM\Mapping as ORM;"

and replace "ORM\" with ""

查看更多
登录 后发表回答