當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::handle方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\Application::handle方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::handle方法的具體用法?PHP Application::handle怎麽用?PHP Application::handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\Application的用法示例。


在下文中一共展示了Application::handle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * @param array $config 配置文件
  */
 public function run(array $config)
 {
     $this->di = new FactoryDefault();
     $this->app = new Application();
     if (defined('APP_ENV') && APP_ENV == 'product') {
         $this->debug = false;
         error_reporting(0);
     } else {
         $this->debug = true;
         error_reporting(E_ALL);
     }
     $this->initConfig($config);
     try {
         $this->onBefore();
         $this->initRouters();
         $this->initUrl();
         $this->initView();
         $this->initDatabase();
         $this->initModelsMetadata();
         $this->initCookie();
         $this->initCrypt();
         $this->initLogger();
         $this->onAfter();
         $this->app->setDI($this->di);
         $this->registerModules();
         echo $this->app->handle()->getContent();
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:c78702505,項目名稱:phalcon-phputils,代碼行數:33,代碼來源:Bootstrap.php

示例2: testTestCase

 public function testTestCase()
 {
     /**
      * ------ NOTE
      * Because i have no more time, only write one test for register motorbike
      * and do not test authentication and other parts
      */
     $this->autheticate();
     $_SERVER["REQUEST_METHOD"] = 'POST';
     $_POST["brand"] = "Honda";
     $_POST["model"] = "CB1100";
     $_POST["cc"] = 250;
     $_POST["color"] = "black";
     $_POST["weight"] = 750;
     $_POST["price"] = 78000000.0;
     $_POST["csrf"] = $this->handleCsrf();
     $fh = fopen($this->di->get('config')->application->testsDir . "tempdata/honda-motorcycle", 'r');
     $tmpfname = tempnam(sys_get_temp_dir(), "img");
     $handle = fopen($tmpfname, "w");
     fwrite($handle, fread($fh, 636958));
     fclose($handle);
     fclose($fh);
     $_FILES["image"] = array("name" => "honda-motorcycles-cb1100.jpg", "type" => "image/jpeg", "tmp_name" => $tmpfname, "error" => "0", "size" => "636958");
     $_SERVER["REQUEST_URI"] = "/motorbikes/create";
     $_GET["_url"] = "/motorbikes/create";
     $request = new Request();
     $this->di->set('request', $request);
     $application = new Application($this->di);
     $files = $request->getUploadedFiles();
     $result = $application->handle()->getContent();
     $this->assertNotFalse(strpos($result, 'motorbike was created successfully'), 'Error in creating motorbike');
 }
開發者ID:sr-hosseini,項目名稱:motorbike,代碼行數:32,代碼來源:TestMotorbikesController.php

示例3: load

 protected function load($uri, $method = "GET", $params = [])
 {
     $_SERVER['REQUEST_METHOD'] = $method;
     $_SERVER['REQUEST_URI'] = $uri;
     switch ($method) {
         case "GET":
             $_GET = $params;
             $_REQUEST = array_merge($_REQUEST, $_GET);
             break;
         case "POST":
             $_POST = $params;
             $_REQUEST = array_merge($_REQUEST, $_POST);
             break;
         case "PUT":
             $_PUT = $params;
             $_REQUEST = array_merge($_REQUEST, $_PUT);
             break;
         default:
             $_REQUEST = $params;
             break;
     }
     foreach ($params as $paramkey => $paramValue) {
         $this->getDi()->get('dispatcher')->setParam($paramkey, $paramValue);
     }
     $application = new Application($this->getDI());
     $_GET['_url'] = $uri;
     $response = $application->handle();
     return json_decode($response->getContent(), true);
 }
開發者ID:boorlyk,項目名稱:friendsApi,代碼行數:29,代碼來源:MainTestCase.php

示例4: handle

 public function handle($uri = null)
 {
     /** @var Response $response */
     $response = parent::handle($uri);
     if ($response->getContent()) {
         return $response;
     }
     switch ($response->getStatusCode()) {
         case Response::HTTP_NOT_FOUND:
         case Response::HTTP_METHOD_NOT_ALLOWED:
         case Response::HTTP_UNAUTHORIZED:
         case Response::HTTP_FORBIDDEN:
         case Response::HTTP_INTERNAL_SERVER_ERROR:
             if ($this->request->isAjax() || $this->request->isJson() || $response instanceof JsonResponse) {
                 $response->setContent(['error' => $response->getStatusMessage()]);
             } else {
                 $template = new Template($this->view, 'error');
                 $template->set('code', $response->getStatusCode());
                 $template->set('message', $response->getStatusMessage());
                 $response->setContent($template->render());
             }
             break;
         default:
             break;
     }
     return $response;
 }
開發者ID:dubhunter,項目名稱:talon,代碼行數:27,代碼來源:RestApplication.php

示例5: testApplicationWithNotFoundRoute

 /**
  * @expectedException \Phalcon\Mvc\Dispatcher\Exception
  */
 public function testApplicationWithNotFoundRoute()
 {
     $appKernel = new TestKernel('dev');
     $appKernel->boot();
     $application = new Application($appKernel->getDI());
     ob_end_clean();
     // application don't close output buffer after exception
     $application->handle('/asdasd111');
 }
開發者ID:ant-hill,項目名稱:phalcon-kernel-module,代碼行數:12,代碼來源:ApplicationTest.php

示例6: run

 /**
  * Runs the application performing all initializations
  *
  * @param $options
  *
  * @return mixed
  */
 public function run($options)
 {
     $loaders = array('session', 'config', 'loader', 'url', 'router', 'view', 'cache', 'markdown');
     foreach ($loaders as $service) {
         $function = 'init' . ucfirst($service);
         $this->{$function}();
     }
     $application = new PhApplication();
     $application->setDI($this->di);
     return $application->handle($_SERVER['REQUEST_URI'])->getContent();
 }
開發者ID:phanbook,項目名稱:portal.phanbook,代碼行數:18,代碼來源:bootstrap.php

示例7: run

 public function run($args = array())
 {
     parent::run($args);
     // initialize our benchmarks
     $this->di['util']->startBenchmark();
     // create the mvc application
     $application = new Application($this->di);
     // run auth init
     $this->di['auth']->init();
     // output the content. our benchmark is finished in the base
     // controller before output is sent.
     echo $application->handle()->getContent();
 }
開發者ID:NavinPanchu,項目名稱:phalcon-boilerplate,代碼行數:13,代碼來源:App.php

示例8: run

 /**
  * @param array $arguments
  * @throws
  */
 public function run($arguments = array())
 {
     $this->autoLoader();
     $this->commonServices();
     $this->customServices();
     if ($this->mode === 'CLI') {
         if (empty($arguments)) {
             throw new \Exception('CLI Require Arguments');
         }
         $this->application->handle($arguments);
     } else {
         echo $this->application->handle()->getContent();
     }
 }
開發者ID:smallmenu,項目名稱:learning-phalcon,代碼行數:18,代碼來源:Bootstrap.php

示例9: run

 /**
  * Runs the application performing all initializations
  *
  * @param $options
  *
  * @return mixed
  */
 public function run($options)
 {
     $loaders = array('session', 'config', 'loader', 'url', 'router', 'view', 'cache');
     foreach ($loaders as $service) {
         $function = 'init' . ucfirst($service);
         $this->{$function}();
     }
     $application = new PhApplication();
     $application->setDI($this->di);
     if (PHP_OS == 'Linux') {
         $uri = $_SERVER['REQUEST_URI'];
     } else {
         $uri = null;
     }
     return $application->handle($uri)->getContent();
 }
開發者ID:zoonman,項目名稱:website,代碼行數:23,代碼來源:bootstrap.php

示例10: run

 /**
  * Runs the application performing all initializations
  *
  * @param $options
  *
  * @return mixed
  */
 public function run($options)
 {
     $loaders = array('config', 'session', 'loader', 'url', 'router', 'database', 'view', 'cache', 'log', 'utils', 'debug');
     try {
         // Handing missing controller errors
         $this->di->set('dispatcher', function () {
             //Create an EventsManager
             $eventsManager = new EventsManager();
             // Attach a listener
             $eventsManager->attach("dispatch:beforeException", function ($event, $dispatcher, $exception) {
                 // Handle 404 exceptions
                 if ($exception instanceof DispatchException) {
                     $dispatcher->forward(array('controller' => 'index', 'action' => 'internalServerError'));
                     return false;
                 }
                 // Alternative way, controller or action doesn't exist
                 if ($event->getType() == 'beforeException') {
                     switch ($exception->getCode()) {
                         case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                         case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                             $dispatcher->forward(array('controller' => 'index', 'action' => 'internalServerError'));
                             return false;
                     }
                 }
             });
             // Instantiate the Security plugin
             $security = new Security($di);
             // Listen for events produced in the dispatcher using the Security plugin
             $eventsManager->attach('dispatch', $security);
             $dispatcher = new \Phalcon\Mvc\Dispatcher();
             // Bind the EventsManager to the dispatcher
             $dispatcher->setEventsManager($eventsManager);
             return $dispatcher;
         }, true);
         foreach ($loaders as $service) {
             $function = 'init' . ucfirst($service);
             $this->{$function}();
         }
         $application = new PhApplication();
         $application->setDI($this->di);
         return $application->handle()->getContent();
     } catch (PhException $e) {
         echo $e->getMessage();
     } catch (\PDOException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:hacktm15,項目名稱:CityBox,代碼行數:54,代碼來源:bootstrap.php

示例11: run

 /**
  * Runs the application performing all initializations
  *
  * @param $options
  *
  * @return mixed
  */
 public function run($options)
 {
     $loaders = array('session', 'config', 'loader', 'url', 'router', 'view', 'cache');
     try {
         foreach ($loaders as $service) {
             $function = 'init' . ucfirst($service);
             $this->{$function}();
         }
         $application = new PhApplication();
         $application->setDI($this->di);
         return $application->handle()->getContent();
     } catch (PhException $e) {
         echo $e->getMessage();
     } catch (\PDOException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:rajeshmsaaryan01,項目名稱:website,代碼行數:24,代碼來源:bootstrap.php

示例12: run

 /**
  * Runs the application performing all initializations
  * 
  * @param $options
  *
  * @return mixed
  */
 public function run($options)
 {
     $loaders = array('config', 'loader', 'environment', 'timezone', 'debug', 'flash', 'url', 'dispatcher', 'view', 'logger', 'database', 'session', 'cache', 'behaviors');
     try {
         foreach ($loaders as $service) {
             $function = 'init' . ucfirst($service);
             $this->{$function}($options);
         }
         $application = new PhApplication();
         $application->setDI($this->_di);
         return $application->handle()->getContent();
     } catch (PhException $e) {
         echo $e->getMessage();
     } catch (\PDOException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:vnlita,項目名稱:phalcon-angular-harryhogfootball,代碼行數:24,代碼來源:Bootstrap.php

示例13: run

 /**
  * 開始運行
  */
 public function run()
 {
     try {
         $this->onBefore();
         $this->initLoader();
         $this->initRouters();
         $this->initUrl();
         $this->initDatabase();
         $this->initModelsMetadata();
         $this->initCookie();
         $this->initLogger();
         $this->initShortFunc();
         \Phalcon\Mvc\Model::setup(['notNullValidations' => false]);
         $this->onAfter();
         $this->app->setDI($this->di);
         $this->registerModules();
         echo $this->app->handle()->getContent();
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:fu-tao,項目名稱:meelier_c,代碼行數:24,代碼來源:Bootstrap.php

示例14:

<?php

use Phalcon\Mvc\Application;
/**
 * Handle the request
 */
$application = new \Phalcon\Mvc\Application($di);
/**
 * Register application modules
 */
if (isset($modules) && !empty($modules)) {
    $application->registerModules($modules);
}
echo $application->handle()->getContent();
開發者ID:vfeitoza,項目名稱:phalcon-multi-module-skeleton,代碼行數:14,代碼來源:application.php

示例15: Crypt

    $crypt = new Crypt();
    $crypt->setKey($config->crypt->key);
    return $crypt;
});
$di->setShared('redis', function () use($config) {
    $redis = new Redis();
    $redis->open($config->redis->host, $config->redis->port);
    return $redis;
});
$di->setShared('session', function () {
    $session = new RedisSessionAdapter(array('path' => 'tcp://127.0.0.1:6379?weight=1'));
    $session->start();
    return $session;
});
$di->set('router', function () {
    $router = new Router();
    $router->add("/:controller/:action/:params", array('module' => 'frontend', 'controller' => 1, 'action' => 2, 'params' => 3));
    $router->add("/admin/:controller/:action/:params", array('module' => 'backend', 'controller' => 1, 'action' => 2, 'params' => 3));
    $router->add("/:controller/([a-z0-9:/+]+)/page:([0-9]+)", array('module' => 'frontend', 'controller' => 1, 'action' => 'index', 'params' => 2, 'page' => 3));
    $router->add("/:controller/([0-9]+)", array('module' => 'frontend', 'controller' => 1, 'action' => 'detail', 'id' => 2));
    $router->add("/", array('module' => 'frontend', 'controller' => 'index', 'action' => 'index'));
    return $router;
});
try {
    $app = new Application($di);
    $app->registerModules(array('frontend' => array('className' => 'Pohome\\Frontend\\Module', 'path' => '../apps/frontend/Module.php'), 'backend' => array('className' => 'Pohome\\Backend\\Module', 'path' => '../apps/backend/Module.php')));
    $response = $app->handle();
    $response->send();
} catch (\Exception $e) {
    echo $e->getMessage();
}
開發者ID:sieg1980,項目名稱:pohome,代碼行數:31,代碼來源:index.php


注:本文中的Phalcon\Mvc\Application::handle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。