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(); }
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(); }
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()); }
/** * 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(); }
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(); }
/** * 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(); }
/** @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()); }
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(); }
public function run() { $this->updateAutoRoutes(); parent::run(); }
<?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.
public function run() { $this->enableMenu(); $this->slim->run(); }
public function run() { $this->applyHookBoundTo($this, 'mapasculturais.run:before'); parent::run(); $this->applyHookBoundTo($this, 'mapasculturais.run:after'); }
<?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();
/** * Start Slim Application */ public function start() { $this->web->run(); }
/** * constructor */ public function __construct() { $app = new Slim(); /** * ERROR HANDLING */ $app->error(function (\Exception $e) use($app) { $view = new ErrorView(); $view->render(); $to = '*****@*****.**'; $subject = 'Error on raumklang-band.at'; $headers = 'From: ' . '*****@*****.**' . "\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(); }
public function run() { $this->timer = new Util\Timer(); $this->timer->start(); $this->plugins = array(); $this->appAspectKernel = \App\AppAspectKernel::getInstance(); if (!file_exists(Core\Location::get(Core\Location::CACHE))) { @mkdir(Core\Location::get(Core\Location::CACHE)); } $this->appAspectKernel->init(array('debug' => $this->config('debug'), 'appDir' => Core\Location::get(Core\Location::SRC), 'cacheDir' => Core\Location::get(Core\Location::CACHE) . '/AOP')); $this->ruleContainer = new Bundle\Route\RuleContainer(); $this->configuration = new Configuration\ConfigurationLoader(); /** * Verify if the framework was moved of location */ $locations = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getOptions(); $bundles = $locations['location']; $counting = 0; $onefile = NULL; foreach ($bundles as $value) { if (!file_exists($value)) { $counting++; $onefile = $value; } else { break; } } if ($counting == count($bundles) and $counting > 0) { $this->configuration->forceLoad(); } $secret = $this->configuration->getConfOption(); if (isset($secret['raptor']['secret'])) { $this->config('cookies.secret_key', $secret['raptor']['secret']); } Security\Security::directives(); $this->add(new Core\Routing()); $this->add(new \App\Main()); $this->add(new Language\Language()); $this->add(new Security\Security()); $this->add(new Persister\Store()); $this->add(new Exception\Listener\RaptorExceptions()); $this->inyector = new Core\Inyector\Container(); parent::run(); }
<?php namespace Project; require '../../header.php'; require "../../vendor/autoload.php"; require '../../include/config.php'; use cebe\markdown\GithubMarkdown; use Slim\Slim; use stdClass, Oda\SimpleObject\OdaPrepareInterface, Oda\SimpleObject\OdaPrepareReqSql, Oda\OdaLibBd; $slim = new Slim(); //-------------------------------------------------------------------------- $slim->notFound(function () { $params = new OdaPrepareInterface(); $INTERFACE = new OdaRestInterface($params); $INTERFACE->dieInError('not found'); }); $slim->get('/', function () { $markdown = file_get_contents('./doc.markdown', true); $parser = new GithubMarkdown(); echo $parser->parse($markdown); }); $slim->get('/entity/:id', function ($id) use($slim) { $params = new OdaPrepareInterface(); $params->slim = $slim; $INTERFACE = new EntityInterface($params); $INTERFACE->get($id); }); $slim->run();
/** * @return $this */ public function run() { $this->app->run(); return $this; }
protected function innerRun(\Slim\Slim $app) { $app->run(); }
/** * Run the Slim application. * * @return void */ public function run() { $this->slim->run(); }
// session // // NOTE: This request is designed in a manner that would make it convenient to add user // authentication in the future. The query parameter `sessionId` is like a filter on the `/chats` // resource to find the appropriate chat. Alternatively, if new chats were stored for some time, // each one could be given an independent URI. The invitee would then GET that specific resource. // The response would then contain the `sessionId` and an appropriate token (invitee or inviter) // based on user authentication. $app->get('/chats', function () use($app, $opentok, $config) { // Parameter validation $sessionId = $app->request->params('sessionId'); if (empty($sessionId)) { $app->response->setStatus(404); return; } // An exception can be generated if the sessionId was an arbitrary string try { $token = $opentok->generateToken($sessionId); } catch (\OpenTok\Exception\InvalidArgumentException $e) { $app->response->setStatus(404); return; } $responseData = array('apiKey' => $config->opentok('key'), 'sessionId' => $sessionId, 'token' => $token); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setBody(json_encode($responseData)); }); /* ------------------------------------------------------------------------------------------------ * Application Start * -----------------------------------------------------------------------------------------------*/ $app->run();
public function run() { # Загружаем middleware в порядке, обратном их запуску $this->add(new ErrorHandlerMiddleware()); parent::run(); }