Default application folder structures as - AppRoot -- apps -- cache -- config -- logs -- modules -- public -- tests -- vendor -- workers The most common workflow is: $engine = new Engine(__DIR__ . '/..'); $engine->loadModules(include __DIR__ . '/../config/modules.php') ->bootstrap() ->run();
Пример #1
0
 public function testPath()
 {
     $engine = new Engine('foo');
     $this->assertEquals('foo', $engine->getAppRoot());
     $this->assertEquals('foo/config', $engine->getConfigPath());
     $this->assertEquals('foo/modules', $engine->getModulesPath());
     $engine->setConfigPath('bar');
     $engine->setModulesPath('bar');
     $this->assertEquals('bar', $engine->getConfigPath());
     $this->assertEquals('bar', $engine->getModulesPath());
 }
Пример #2
0
 /**
  * 注册全局的服务,需在 app 或者 其他 module 中的 registerServices 手动调用。
  *
  * @param \Phalcon\DiInterface $di
  */
 public static function registerGlobalServices($di)
 {
     $config = $di->getConfig();
     // 当用户系统和
     if (!empty($config->user->dbAdapter)) {
         $di->set('userDbMaster', function () use($di, $config) {
             $slaves = $config->user->dbAdapter->slave;
             $slaveKey = array_rand($slaves->toArray());
             if (!isset($slaves->{$slaveKey}) || count($slaves) < 1) {
                 throw new Exception\RuntimeException(sprintf('No DB slave options found'));
             }
             return Engine::diDbAdapter($slaves->{$slaveKey}->adapter, $slaves->{$slaveKey}->toArray(), $di);
         });
         $di->set('userDbSlave', function () use($di, $config) {
             $slaves = $config->user->dbAdapter->slave;
             $slaveKey = array_rand($slaves->toArray());
             if (!isset($slaves->{$slaveKey}) || count($slaves) < 1) {
                 throw new Exception\RuntimeException(sprintf('No DB slave options found'));
             }
             return Engine::diDbAdapter($slaves->{$slaveKey}->adapter, $slaves->{$slaveKey}->toArray(), $di);
         });
     }
 }
Пример #3
0
<?php

require __DIR__ . '/../init_autoloader.php';
use Eva\EvaEngine\Engine;
$engine = new Engine(__DIR__ . '/..');
$engine->loadModules(include __DIR__ . '/../config/modules.' . $engine->getAppName() . '.php')->bootstrap()->run();