bootstrap.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use PhalApi\Logger;
  3. use PhalApi\Logger\ExplorerLogger;
  4. use PhalApi\Config\FileConfig;
  5. use PhalApi\Database\NotORMDatabase;
  6. require_once dirname(__FILE__) . '/../vendor/autoload.php';
  7. defined('API_ROOT') || define('API_ROOT', dirname(__FILE__));
  8. $di = \PhalApi\DI();
  9. $di->logger = new ExplorerLogger(
  10. Logger::LOG_LEVEL_DEBUG | Logger::LOG_LEVEL_INFO | Logger::LOG_LEVEL_ERROR);
  11. $di->config = new FileConfig(dirname(__FILE__) . '/../config');
  12. $di->debug = true;
  13. $dbsCfg = array(
  14. 'servers' => array(
  15. 'db_master' => array( //服务器标记
  16. 'host' => '127.0.0.1', //数据库域名
  17. 'name' => 'phalapi', //数据库名字
  18. 'user' => 'root', //数据库用户名
  19. 'password' => '123', //数据库密码
  20. 'port' => 3306, //数据库端口
  21. 'charset' => 'UTF8', //数据库字符集
  22. ),
  23. ),
  24. 'tables' => array(
  25. '__default__' => array(
  26. 'prefix' => 'tbl_',
  27. 'key' => 'id',
  28. 'map' => array(
  29. array('db' => 'db_master'),
  30. ),
  31. ),
  32. ),
  33. );
  34. $taskMqCfg = $di->config->get('dbs');
  35. $dbsCfg['tables'] = array_merge($dbsCfg['tables'], $taskMqCfg['tables']);
  36. $di->notorm = new NotORMDatabase($dbsCfg, true);