当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim::run方法代码示例

本文整理汇总了PHP中Slim\Slim::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::run方法的具体用法?PHP Slim::run怎么用?PHP Slim::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Slim的用法示例。


在下文中一共展示了Slim::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: request

 private function request($method, $path, $data = array(), $optionalHeaders = array())
 {
     // Capture STDOUT
     ob_start();
     $options = array('REQUEST_METHOD' => strtoupper($method), 'PATH_INFO' => $path, 'SERVER_NAME' => 'local.dev');
     if ($method === 'get') {
         $options['QUERY_STRING'] = http_build_query($data);
     } elseif (is_array($data)) {
         $options['slim.input'] = http_build_query($data);
     } else {
         $options['slim.input'] = $data;
     }
     // Prepare a mock environment
     Slim\Environment::mock(array_merge($options, $optionalHeaders));
     $env = Slim\Environment::getInstance();
     $this->app->router = new NoCacheRouter($this->app->router);
     $this->app->request = new Slim\Http\Request($env);
     // Custom headers
     $this->app->request->headers = new Slim\Http\Headers($env);
     $this->app->response = new Slim\Http\Response();
     // Establish some useful references to the slim app properties
     $this->request = $this->app->request();
     $this->response = $this->app->response();
     // Execute our app
     $this->app->run();
     // Return the application output. Also available in `response->body()`
     return ob_get_clean();
 }
开发者ID:hochanh,项目名称:slim-test-helpers,代码行数:28,代码来源:WebTestClient.php

示例2: getConfig

 function __construct()
 {
     static::$instance = $this;
     $env = getConfig('Enviroments/enviroment.config.php');
     $config = getConfig("Enviroments/{$env}.config.php");
     $config['enviroment'] = $env;
     //debug mode
     $debug = isset($_GET['debug']) ? 10 : $config['debugMode'];
     if ($debug) {
         ini_set('display_errors', 1);
         error_reporting(E_ALL);
     } else {
         ini_set('display_errors', 0);
         error_reporting(0);
     }
     //read rewritebase
     $htaccess = file_get_contents(BASE_DIR . '/Docroot/.htaccess');
     preg_match('@RewriteBase\\s*(.*)$@m', $htaccess, $matches);
     $this->rewriteBase = $matches[1];
     //create slim instance
     \Slim\Slim::registerAutoloader();
     $this->slim = new \Slim\Slim(array('cookies.encrypt' => true, 'cookies.lifetime' => 20 * 365 * 24 * 60 . ' minutes', 'cookies.path' => $this->rewriteBase, 'cookies.secure' => false, 'cookies.secret_key' => $config['cryptSecrect']));
     //config session
     $this->slim->add(new \Slim\Middleware\SessionCookie(array('expires' => 20 * 365 * 24 * 60 . ' minutes', 'path' => $this->rewriteBase, 'domain' => null, 'secure' => false, 'name' => 'slim_session', 'secret' => $config['cryptSecrect'])));
     //routing
     require_once BASE_DIR . '/routes.php';
     $this->appendRoute($routes);
     //database
     DB::config($config['db']['type'], $config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $debug);
     //run slim application
     $this->slim->run();
 }
开发者ID:hopitio,项目名称:framework,代码行数:32,代码来源:Bootstrap.php

示例3: run

 public function run()
 {
     try {
         $this->_slim->run();
     } catch (Exception $e) {
         $this->error($e);
     }
     $this->_storage->store($this->_basketService->getBasketArrayCopy(), $this->_basketService->getProductArrayCopy(), $this->_basketService->getBasketItemArrayCopy());
 }
开发者ID:skieff,项目名称:BSA2015-Basket-RestApi,代码行数:9,代码来源:RestApi.php

示例4: run

 /**
  * Run application, using configuration defined by previous method
  * @see addStore
  */
 public function run()
 {
     $r = new \SameAsLite\RouteConfig($this);
     $r->setup();
     // add datasets to template
     $this->app->view()->set('datasets', $this->storeOptions);
     // run (Slim)
     $this->app->run();
 }
开发者ID:joetm,项目名称:sameAs-Lite,代码行数:13,代码来源:WebApp.php

示例5: run

 public function run()
 {
     if (isset($_GET['refresh'])) {
         $this->import();
     }
     $this->slim->get('/', function () {
         $controller = new \Controller\IndexController();
         $controller->indexAction();
     })->name('index');
     $this->slim->get('/portfolio/:album', function ($album) {
         $controller = new \Controller\PortfolioController();
         $controller->albumAction($album);
     })->name('album');
     $this->slim->get('/portfolio/:album/:image', function ($album, $image) {
         $controller = new \Controller\PortfolioController();
         $controller->imageAction($album, $image);
     })->name('image');
     $this->slim->run();
 }
开发者ID:alexdevid,项目名称:darinaerde,代码行数:19,代码来源:Portfolio.php

示例6: run

 /**
  * This function starts the Slim framework by calling it's run() method.
  */
 public function run()
 {
     $responseOutputWriter =& $this->_hook->getResponseOutputWriter();
     // define index endpoint
     $indexEndpoint = new SlimBootstrap\Endpoint\Index($this->_collectionEndpoints);
     $this->_app->get('/', function () use(&$responseOutputWriter, $indexEndpoint) {
         $responseOutputWriter->write($indexEndpoint->get());
     })->name('index');
     // define info endpoint
     $infoEndpoint = new SlimBootstrap\Endpoint\Info();
     $this->_app->get('/info', function () use(&$responseOutputWriter, $infoEndpoint) {
         $responseOutputWriter->write($infoEndpoint->get());
     })->name('info');
     $this->_app->run();
 }
开发者ID:bigpoint,项目名称:slim-bootstrap,代码行数:18,代码来源:Bootstrap.php

示例7: EventPublisher

 /** @test */
 function it_should_persist_an_event_published_inside_an_slim_route()
 {
     /** @var \Hexagonal\Bridges\Doctrine2\DomainEvents\EventStoreRepository $store */
     $store = $this->entityManager->getRepository(StoredEvent::class);
     $publisher = new EventPublisher();
     $middleware = new StoreEventsMiddleware(new PersistEventsSubscriber($store, new StoredEventFactory(new JsonSerializer())), $publisher);
     $app = new Slim();
     $app->get('/', function () use($publisher) {
         $events = new SplObjectStorage();
         $events->attach(A::transferWasMadeEvent()->build());
         $publisher->publish($events);
     });
     $app->add($middleware);
     Environment::mock(['REQUEST_METHOD' => 'GET']);
     $app->run();
     $this->assertCount(1, $store->allEvents());
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:18,代码来源:StoreEventsMiddlewareTest.php

示例8: load_slim

 public function load_slim()
 {
     $slim = new Slim($this->slim_settings);
     foreach ($this->routes as $old_route) {
         $name = isset($old_route[self::SLIM_NAME]) && is_string($old_route[self::SLIM_NAME]) ? $old_route[self::SLIM_NAME] : null;
         $pattern = isset($old_route[self::SLIM_PATTERN]) && is_string($old_route[self::SLIM_PATTERN]) ? $old_route[self::SLIM_PATTERN] : null;
         $methods = isset($old_route[self::SLIM_METHODS]) && is_array($old_route[self::SLIM_METHODS]) ? $old_route[self::SLIM_METHODS] : null;
         $resolver = isset($old_route[self::SLIM_RESOLVER]) && is_callable($old_route[self::SLIM_RESOLVER]) ? $old_route[self::SLIM_RESOLVER] : null;
         $auth = isset($old_route[self::SLIM_AUTH]) && is_string(self::SLIM_AUTH) ? $old_route[self::SLIM_AUTH] : null;
         $conditions = isset($old_route[self::SLIM_CONDS]) && is_array($old_route[self::SLIM_CONDS]) ? $old_route[self::SLIM_CONDS] : null;
         if ($name == null || $pattern == null || $methods == null || $resolver == null || $auth == null) {
             continue;
         }
         $route = $slim->map($pattern, Authorization::hook($auth), $resolver);
         $route->via($methods);
         $route->name($name);
         if ($conditions != null) {
             $route->conditions($conditions);
         }
     }
     $slim->run();
 }
开发者ID:rulosan,项目名称:secprog,代码行数:22,代码来源:Application.php

示例9: run

 public function run()
 {
     $this->updateAutoRoutes();
     parent::run();
 }
开发者ID:dannykopping,项目名称:spore,代码行数:5,代码来源:Spore.php

示例10: Slim

<?php

require '../vendor/autoload.php';
use Slim\Slim;
Slim::registerAutoloader();
$AchieveCraftApp = new Slim(array("settings" => array("determineRouteBeforeAppMiddleware" => true, "debug" => true)));
$AchieveCraftApp->config("baseDir", "../");
$AchieveCraftApp->config(require_once $AchieveCraftApp->config("baseDir") . "config.php");
require_once $AchieveCraftApp->config("paths")['backend']['AchieveCraft'];
use jdf221\AchieveCraft\AchieveCraft;
$AchieveCraft = new AchieveCraft($AchieveCraftApp);
$routers = glob($AchieveCraft->App()->config("paths")['routes'] . '*.route.php');
foreach ($routers as $router) {
    require_once $router;
}
$AchieveCraftApp->run();
//TODO: Maybe move the Achievement and Icon class into it's own composer package. Then create it's own github repo and use the composer.json for loading it.
开发者ID:xmx1024,项目名称:AchieveCraft,代码行数:17,代码来源:index.php

示例11: run

 public function run()
 {
     $this->enableMenu();
     $this->slim->run();
 }
开发者ID:louislam,项目名称:louislam-crud,代码行数:5,代码来源:SlimLouisCRUD.php

示例12: run

 public function run()
 {
     $this->applyHookBoundTo($this, 'mapasculturais.run:before');
     parent::run();
     $this->applyHookBoundTo($this, 'mapasculturais.run:after');
 }
开发者ID:baldasso,项目名称:mapasculturais,代码行数:6,代码来源:App.php

示例13: Slim

<?php

/**
 * @package Places
 * @author Paul Grattan
 */
use Slim\Slim;
use PlaceFinder\Service\Service;
// include the autoloader for composer packages
if (!@(include_once 'vendor/autoload.php')) {
    throw new \Exception('Composer autoload and modules are required.');
}
// Router to handle POSTed JSON
$router = new Slim();
$postHandler = new Service();
/**
 * Accept incoming requests on root domain. Ideally the slim router should check 
 * request headers are correct application/json type 
 */
$router->post('/', function () use($router, $postHandler) {
    return $postHandler->parseTradeMessage($router->request->getBody());
});
// Placeholder
$router->get('/', function () {
    return 'Welcome';
});
$router->run();
开发者ID:paulinthought,项目名称:service,代码行数:27,代码来源:index.php

示例14: start

 /**
  * Start Slim Application
  */
 public function start()
 {
     $this->web->run();
 }
开发者ID:yorch81,项目名称:v3application,代码行数:7,代码来源:V3Application.class.php

示例15: __construct

 /**
  * constructor
  */
 public function __construct()
 {
     $app = new Slim();
     /**
      * ERROR HANDLING
      */
     $app->error(function (\Exception $e) use($app) {
         $view = new ErrorView();
         $view->render();
         $to = 'akuehne9878@gmail.com';
         $subject = 'Error on raumklang-band.at';
         $headers = 'From: ' . 'do-not-reply@raumklang-band.at' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         mail($to, $subject, $e->getMessage() . "\n\n" . $e->getTraceAsString(), $headers);
     });
     $app->notFound(function () use($app) {
         $view = new Error404View();
         $view->render();
     });
     /**
      * ROUTE DEFINITIONS
      */
     $app->get('/', function () use($app) {
         try {
             $useCase = new UCShowLandingPage();
             $useCase->renderView();
         } catch (\Exception $e) {
             $app->error($e);
         }
     });
     $app->post("/mail", function () use($app) {
         try {
             $name = $app->request()->params('name');
             $email = $app->request()->params('email');
             $message = $app->request()->params('message');
             $useCase = new UCSendMessage();
             $useCase->execute($name, $email, $message);
         } catch (\Exception $e) {
             $app->error($e);
         }
     });
     $app->get("/impressum", function () use($app) {
         try {
             $useCase = new UCShowImpressum();
             $useCase->renderView();
         } catch (\Exception $e) {
             $app->error($e);
         }
     });
     $app->get("/projekt", function () use($app) {
         try {
             $useCase = new UCShowProjekt();
             $useCase->renderView();
         } catch (\Exception $e) {
             $app->error($e);
         }
     });
     $app->post("/morePhotos", function () use($app) {
         try {
             $useCase = new UCLoadAllGalleries();
             $useCase->loadAllGalleries();
         } catch (\Exception $e) {
             $app->error($e);
         }
     });
     /**
      * RUN :-)
      */
     $app->run();
 }
开发者ID:akuehne9878,项目名称:website,代码行数:72,代码来源:ApplicationFrontController.php


注:本文中的Slim\Slim::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。