CodeIgniter2的Doctrine2 CLI

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeIgniter2的Doctrine2 CLI相关的知识,希望对你有一定的参考价值。

  1. <?php
  2. chdir(dirname(__FILE__) . '/libraries');
  3.  
  4. require_once 'Doctrine/Common/ClassLoader.php';
  5.  
  6. $classLoader = new DoctrineCommonClassLoader('Doctrine');
  7. $classLoader->register();
  8.  
  9. $classLoader = new DoctrineCommonClassLoader('Symfony', 'Doctrine');
  10. $classLoader->register();
  11.  
  12. $configFile = '../cli-config.php';
  13. $helperSet = null;
  14. if (file_exists($configFile)) {
  15. if ( ! is_readable($configFile)) {
  16. 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
  17. );
  18. }
  19.  
  20. require $configFile;
  21.  
  22. foreach ($GLOBALS as $helperSetCandidate) {
  23. if ($helperSetCandidate instanceof SymfonyComponentConsoleHelperHelperSet) {
  24. $helperSet = $helperSetCandidate;
  25. break;
  26. }
  27. }
  28. }
  29.  
  30. $helperSet = ($helperSet) ?: new SymfonyComponentConsoleHelperHelperSet();
  31.  
  32. $cli = new SymfonyComponentConsoleApplication('Doctrine Command Line Interface', DoctrineORMVersion::VERSION);
  33. $cli->setCatchExceptions(true);
  34. $cli->setHelperSet($helperSet);
  35. $cli->addCommands(array(
  36. // DBAL Commands
  37. new DoctrineDBALToolsConsoleCommandRunSqlCommand(),
  38. new DoctrineDBALToolsConsoleCommandImportCommand(),
  39.  
  40. // ORM Commands
  41. new DoctrineORMToolsConsoleCommandClearCacheMetadataCommand(),
  42. new DoctrineORMToolsConsoleCommandClearCacheResultCommand(),
  43. new DoctrineORMToolsConsoleCommandClearCacheQueryCommand(),
  44. new DoctrineORMToolsConsoleCommandSchemaToolCreateCommand(),
  45. new DoctrineORMToolsConsoleCommandSchemaToolUpdateCommand(),
  46. new DoctrineORMToolsConsoleCommandSchemaToolDropCommand(),
  47. new DoctrineORMToolsConsoleCommandEnsureProductionSettingsCommand(),
  48. new DoctrineORMToolsConsoleCommandConvertDoctrine1SchemaCommand(),
  49. new DoctrineORMToolsConsoleCommandGenerateRepositoriesCommand(),
  50. new DoctrineORMToolsConsoleCommandGenerateEntitiesCommand(),
  51. new DoctrineORMToolsConsoleCommandGenerateProxiesCommand(),
  52. new DoctrineORMToolsConsoleCommandConvertMappingCommand(),
  53. new DoctrineORMToolsConsoleCommandRunDqlCommand(),
  54. new DoctrineORMToolsConsoleCommandValidateSchemaCommand(),
  55.  
  56. ));
  57. $cli->run();

以上是关于CodeIgniter2的Doctrine2 CLI的主要内容,如果未能解决你的问题,请参考以下文章

CodeIgniter2的Doctrine2包装器-开发配置。

CodeIgniter2的Doctrine2 CLI

PHP cli-config.php - doctrine2 + codeigniter2

在 Doctrine 2 / CodeIgniter 2 中找不到实体模型

将 Codeigniter 2 与 Doctrine ORM 2 < PHP v5.2 一起使用

添加相关实体时,Doctrine 对象未设置外键