/** * Handles the request and delivers the response. * * @param Request|null $request Request to process */ public function run(BaseRequest $request = null) { if (null === $request) { $request = Request::createFromGlobals(); } parent::run($request); }
/** * {@inheritdoc} */ public function run(Request $request = null) { if ($this['config']->get('general/caching/request')) { $this['http_cache']->run($request); } else { parent::run($request); } }
/** * Overrides Silex's Application::run to handle console requests instead * of HTTP requests if the PHP SAPI name is cli * * {@inheritDoc} */ public function run(Request $request = null) { if (php_sapi_name() !== 'cli') { return parent::run($request); } if (!$this->booted) { $this->boot(); } $this['console']->run(); }
public function testFinishFilter() { $containerTarget = array(); $app = new Application(); $app->finish(function () use(&$containerTarget) { $containerTarget[] = '4_filterFinish'; }); $app->get('/foo', function () use(&$containerTarget) { $containerTarget[] = '1_routeTriggered'; return new StreamedResponse(function () use(&$containerTarget) { $containerTarget[] = '3_responseSent'; }); }); $app->after(function () use(&$containerTarget) { $containerTarget[] = '2_filterAfter'; }); $app->run(Request::create('/foo')); $this->assertSame(array('1_routeTriggered', '2_filterAfter', '3_responseSent', '4_filterFinish'), $containerTarget); }
public function run(Request $request = null) { $this->initialize(); parent::run($request); }
/** * @param Request|null $request */ public function run(Request $request = null) { $this['request'] = $this->factory(function () { return $this['request_stack']->getCurrentRequest(); }); $this->before(function (Request $request) { $this["route"] = ['name' => $request->attributes->get("_route"), 'params' => $request->attributes->get("_route_params")]; if (strpos($request->headers->get("Content-Type"), "application/json") === 0) { $data = json_decode($request->getContent(), true); $request->request->replace(is_array($data) ? $data : []); } }); parent::run($request); }
/** * Executes the Silex\Application->run() method * * @return void */ public function run() { self::$application->run(); }
<?php require_once 'vendor/autoload.php'; require_once 'FileHelper.php'; use Silex\Application; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new Silex\Application(); $app->post('/upload', function (Request $request) use($app) { // get file from requests $file = $request->files->get('image'); // if null return error if ($file == null) { $obj = new stdClass(); $obj->success = false; $obj->error = "No image provided"; return json_encode($obj); } // upload the file and return the json with the data return json_encode(FileHelper::writeFile($file)); }); $app->run();
public function run() { $this->application->run(); }
/** * @param Request $request * @return mixed */ public function run(Request $request = null) { if (php_sapi_name() === 'cli') { return $this->getConsole()->run(); } return parent::run($request); }
/** * Execute application */ public function run() { $this->app->run(); }
public function run(Request $request = null) { parent::run($request); }
public function run(\Symfony\Component\HttpFoundation\Request $request = NULL) { // Initialisation of Flint $this->setupServicesAndConfig(); // Initialisation of Silex $serviceOverride = null; if (method_exists($this, 'init')) { $serviceOverride = $this->init(); } /** * Allows you to override the parent::run() method with a service inside the locator, * usually used for http_cache and other plugins */ if ($serviceOverride !== null) { return $serviceOverride->run($request); } return parent::run($request); }
}); $application->get('/unique-number-repository/{name}', function (Application $application, $name) use($locator) { //begin of runtime parameters $name = urldecode($name); //end of runtime parameters //begin of dependencies $numberStorage = $locator->getUniqueNumberStorage(); $repositoryStorage = $locator->getRepositoryStorage(); //end of dependencies //begin of validation $repositoryStorage->filterByName($name); $repositoryDoesNotExist = !$repositoryStorage->has(); if ($repositoryDoesNotExist) { $application->abort(404, 'repository does not exist'); } $repositoryStorage->resetRuntimeProperties(); //end of validation //begin of process $numberStorage->resetRuntimeProperties(); $numberStorage->filterBy('repository_name', $name); $collection = $numberStorage->readMany(); $content = array(); foreach ($collection as $uniqueNumberRequest) { $content[] = array('number' => $uniqueNumberRequest->number()); } return $application->json($content); //end of process }); //end of routing $application->run();
public function run() { $this->silex->run(); }
/** * Finalizes the startup process and sends the run command to the Silex instance. * * @return void */ public function startupSite() { $this->app->run(); }
/** * Run this application */ public function run() { // Run app $this->app->run(); }
use Kumatch\BBSAPI\Application\Provider\DoctrineORMServiceProvider; use Kumatch\BBSAPI\Application\Provider\BBSAPIServiceProvider; use Kumatch\BBSAPI\Application\Provider\BBSAPIUserServiceProvider; use Kumatch\BBSAPI\Application\Provider\BBSAPIThreadServiceProvider; $loader = (require_once __DIR__ . '/../vendor/autoload.php'); $config = (require_once __DIR__ . "/../config/config.php"); AnnotationRegistry::registerLoader(array($loader, 'loadClass')); $req = Request::createFromGlobals(); $app = new Application(); $app->register(new JsonBodyProvider()); $app->register(new DoctrineORMServiceProvider(), ["doctrine_orm.config" => $config["doctrine"]]); $app->register(new BBSAPIServiceProvider(), ["salt" => $config["salt"]]); $app->register(new BBSAPIUserServiceProvider()); $app->register(new BBSAPIThreadServiceProvider()); $app->get("/", function (Application $app) { $composerJSON = json_decode(file_get_contents(__DIR__ . "/../composer.json"), true); return $app->json(["version" => $composerJSON["version"]]); }); $app->error(function (\Exception $e, $code) use($app) { switch ($code) { case 404: return $app->json(["message" => "not found."], 404); case 405: return $app->json(["message" => $e->getMessage()], 405); default: //error_log($e->getMessage()); return $app->json(["message" => "sorry server error"], 500); } }); $app->run($req);
/** * Custom Application Run */ function run(Request $request = NULL) { $app = $this; $this->before(function () use($app) { foreach ($app->setModules() as $module) { $module->registerTemplatesPathTwig($app); } }); parent::run($request); }