Beispiel #1
0
 public static function getAppInstance()
 {
     if (!self::$appInstance) {
         try {
             /**
              * Read the configuration
              */
             $config = (include APP_PATH . "/app/config/config.php");
             /**
              * Read auto-loader
              */
             include APP_PATH . "/app/config/loader.php";
             /**
              * Read services
              */
             $di = self::getDiInstance();
             include APP_PATH . "/app/config/services.php";
             /**
              * Handle the Route
              */
             self::$appInstance = new \Phalcon\Mvc\Micro($di);
             $syncRoute = new Phalcon\Mvc\Micro\Collection();
             // $syncRoute->setHandler(new SyncController($di));
             $syncRoute->setHandler('SyncController', true);
             $syncRoute->setPrefix('sync/');
             $syncRoute->map('get_user/{api}/{guid}', 'indexAction');
             $syncRoute->map('add_user/{api}/{guid}', 'addUserAction');
             $syncRoute->map('update_user/{api}/{guid}', 'updateUserAction');
             $syncRoute->map('insert_user/{api}/{guid}', 'insertUserAction');
             $syncRoute->map('plus_user/{api}/{guid}', 'plusUserAction');
             self::$appInstance->mount($syncRoute);
             $asyncRoute = new Phalcon\Mvc\Micro\Collection();
             // $asyncRoute->setHandler(new AsyncController($di));
             $asyncRoute->setHandler('AsyncController', true);
             $asyncRoute->setPrefix('async/');
             $asyncRoute->map('add_user/{api}/{guid}', 'addUserAction');
             $asyncRoute->map('update_user/{api}/{guid}', 'updateUserAction');
             $asyncRoute->map('insert_user/{api}/{guid}', 'insertUserAction');
             $asyncRoute->map('plus_user/{api}/{guid}', 'plusUserAction');
             self::$appInstance->mount($asyncRoute);
             file_put_contents("/tmp/sw_server_instance.log", "new AppInstance" . date("Y-m-d H:i:s") . "\r\n", FILE_APPEND);
         } catch (\Exception $e) {
             echo $e->getMessage() . '<br>';
             echo '<pre>' . $e->getTraceAsString() . '</pre>';
         }
     }
     return self::$appInstance;
 }
Beispiel #2
0
 public static function getAppInstance()
 {
     if (!self::$appInstance) {
         try {
             /**
              * Read the configuration
              */
             $config = (include APP_PATH . "/app/config/config.php");
             /**
              * Read auto-loader
              */
             include APP_PATH . "/app/config/loader.php";
             /**
              * Read services
              */
             $di = self::getDiInstance();
             include APP_PATH . "/app/config/services.php";
             self::$appInstance = new \Phalcon\Mvc\Micro($di);
             /**
              * Handle the Route, Sync RPC handler
              */
             $syncRoute = new Phalcon\Mvc\Micro\Collection();
             $syncRoute->setHandler('IndexController', true);
             $syncRoute->setPrefix('sync/');
             $syncRoute->map('getUserById/{key}', 'getUserByIdAction');
             $syncRoute->map('checkUserLoginInfo/{key}', 'checkUserLoginInfoAction');
             $syncRoute->map('checkLoginName/{key}', 'checkLoginNameAction');
             $syncRoute->map('addUser/{key}', 'addUserAction');
             $syncRoute->map('updateUser/{key}', 'updateUserAction');
             $syncRoute->map('deleteUser/{key}', 'deleteUserAction');
             $syncRoute->map('getUsers/{key}', 'getUsersAction');
             self::$appInstance->mount($syncRoute);
             /**
              * More, just like Async RPC handler
              */
         } catch (\Exception $e) {
             echo $e->getMessage() . '<br>';
             echo '<pre>' . $e->getTraceAsString() . '</pre>';
         }
     }
     return self::$appInstance;
 }
 public function testMicroCollectionsLazy()
 {
     Phalcon\DI::reset();
     $app = new Phalcon\Mvc\Micro();
     $collection = new Phalcon\Mvc\Micro\Collection();
     $collection->setHandler('PersonasLazyController', true);
     $collection->map('/', 'index');
     $collection->map('/edit/{number}', 'edit');
     $app->mount($collection);
     $app->handle('/');
     $this->assertEquals(PersonasLazyController::getEntered(), 1);
     $app->handle('/edit/100');
     $this->assertEquals(PersonasLazyController::getEntered(), 101);
 }