本文整理汇总了PHP中Silex\Application::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::run方法的具体用法?PHP Application::run怎么用?PHP Application::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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);
}
示例2: run
/**
* {@inheritdoc}
*/
public function run(Request $request = null)
{
if ($this['config']->get('general/caching/request')) {
$this['http_cache']->run($request);
} else {
parent::run($request);
}
}
示例3: run
/**
* 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();
}
示例4: testFinishFilter
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);
}
示例5: run
public function run(Request $request = null)
{
$this->initialize();
parent::run($request);
}
示例6: run
/**
* @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);
}
示例7: run
/**
* Executes the Silex\Application->run() method
*
* @return void
*/
public function run()
{
self::$application->run();
}
示例8: function
<?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();
示例9: run
public function run()
{
$this->application->run();
}
示例10: 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);
}
示例11: run
/**
* Execute application
*/
public function run()
{
$this->app->run();
}
示例12: run
public function run(Request $request = null)
{
parent::run($request);
}
示例13: run
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);
}
示例14: function
});
$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();
示例15: run
public function run()
{
$this->silex->run();
}