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


PHP Request::createFromBase方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request instanceof Request) {
         $request = Request::createFromBase($request);
     }
     $response = $next($request);
     if (!is_null($this->esi)) {
         $this->esi->addSurrogateControl($response);
     }
     return $response;
 }
开发者ID:okaufmann,项目名称:laravel-httpcache,代码行数:18,代码来源:ParseEsi.php

示例2: createRequest

 protected function createRequest($method = 'GET')
 {
     $request = LaravelRequest::createFromBase(LaravelRequest::create('/', 'GET'));
     if ($method !== null) {
         $request->headers->set('Access-Control-Request-Method', $method);
     }
     return new Request($request);
 }
开发者ID:trunda,项目名称:php-cors,代码行数:8,代码来源:MethodMatcherTest.php

示例3: initialize

 /**
  * Initialize the Laravel framework.
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $this->oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $this->oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     // Load the application object
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     $this->app->instance('middleware.disable', $this->module->config['disable_middleware']);
     // Reset the old database after the DatabaseServiceProvider ran.
     // This way other service providers that rely on the $app['db'] entry
     // have the correct instance available.
     if ($this->oldDb) {
         $this->app['events']->listen('Illuminate\\Database\\DatabaseServiceProvider', function () {
             $this->app->singleton('db', function () {
                 return $this->oldDb;
             });
         });
     }
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // If events should be disabled mock the event dispatcher instance
     if ($this->module->config['disable_events']) {
         $this->mockEventDispatcher();
     }
     // Setup an event listener to listen for all events that are triggered
     $this->setupEventListener();
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:53,代码来源:Laravel5.php

示例4: initialize

 /**
  * Initialize the Laravel framework.
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     // Load the application object
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     $this->app->instance('middleware.disable', $this->module->config['disable_middleware']);
     // Bootstrap the application
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Restore the old database object if available
     if ($oldDb) {
         $this->app['db'] = $oldDb;
         Model::setConnectionResolver($this->app['db']);
     }
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
开发者ID:Dossar,项目名称:boltbse,代码行数:43,代码来源:Laravel5.php

示例5: initialize

 /**
  * Initialize the Laravel framework.
  */
 private function initialize()
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $oldDb = $this->app['db'];
     }
     // The module can login a user with the $I->amLoggedAs() method,
     // but this is not persisted between requests. Store a reference
     // to the logged in user to simulate this.
     $loggedInUser = null;
     if ($this->app['auth'] && $this->app['auth']->check()) {
         $loggedInUser = $this->app['auth']->user();
     }
     $this->app = $this->kernel = $this->loadApplication();
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Set the base url for the Request object
     $url = $this->app['config']->get('app.url', 'http://localhost');
     $this->app->instance('request', Request::createFromBase(SymfonyRequest::create($url)));
     if ($oldDb) {
         $this->app['db'] = $oldDb;
         Model::setConnectionResolver($this->app['db']);
     }
     // If there was a user logged in restore this user.
     // Also reload the user object from the user provider to prevent stale user data.
     if ($loggedInUser) {
         $refreshed = $this->app['auth']->getProvider()->retrieveById($loggedInUser->getAuthIdentifier());
         $this->app['auth']->setUser($refreshed ?: $loggedInUser);
     }
     $this->module->setApplication($this->app);
 }
开发者ID:corcre,项目名称:elabftw,代码行数:35,代码来源:Laravel5.php

示例6: createRequest

 protected function createRequest($origin = null)
 {
     $request = LaravelRequest::createFromBase(LaravelRequest::create('/', 'GET'));
     if ($origin !== null) {
         $request->headers->set('Origin', $origin);
     }
     return new Request($request);
 }
开发者ID:trunda,项目名称:php-cors,代码行数:8,代码来源:OriginMatcherTest.php

示例7: run

 /**
  * @return \Illuminate\Http\Response
  */
 public function run()
 {
     $request = Request::createFromBase(Request::createFromGlobals());
     return $this->handle($request);
 }
开发者ID:bogdananton,项目名称:multi-routing,代码行数:8,代码来源:App.php

示例8: createRequest

 protected function createRequest($headers = ['X-Test'])
 {
     $request = LaravelRequest::createFromBase(LaravelRequest::create('/', 'GET'));
     if ($headers !== null) {
         $request->headers->set('Access-Control-Request-Headers', implode(', ', $headers));
     }
     return new Request($request);
 }
开发者ID:trunda,项目名称:php-cors,代码行数:8,代码来源:HeaderMatcherTest.php

示例9: call

 /**
  * Call the given URI and return the Response.
  *
  * @param  string  $method
  * @param  string  $uri
  * @param  array  $parameters
  * @param  array  $cookies
  * @param  array  $files
  * @param  array  $server
  * @param  string  $content
  * @return \Illuminate\Http\Response
  */
 public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
 {
     $kernel = $this->app->make(HttpKernel::class);
     $files = array_merge($files, $this->extractFilesFromDataArray($parameters));
     $symfonyRequest = SymfonyRequest::create($this->prepareUrlForRequest($uri), $method, $parameters, $cookies, $files, array_replace($this->serverVariables, $server), $content);
     $response = $kernel->handle($request = Request::createFromBase($symfonyRequest));
     $kernel->terminate($request, $response);
     return $this->createTestResponse($response);
 }
开发者ID:jarnovanleeuwen,项目名称:framework,代码行数:21,代码来源:MakesHttpRequests.php

示例10: url

 /**
  * Return a UrlGenerator object 
  *
  * @return \Illuminate\Routing\UrlGenerator
  */
 public function url()
 {
     $routes = new \Illuminate\Routing\RouteCollection();
     $context = \Illuminate\Http\Request::createFromBase(\Illuminate\Http\Request::capture());
     return new \Illuminate\Routing\UrlGenerator($routes, $context);
 }
开发者ID:Codex-NG,项目名称:cornexaac,代码行数:11,代码来源:Http.php

示例11: terminate

 /**
  * Terminates a request/response cycle.
  *
  * @param SyfmonyRequest $request A Request instance
  * @param Response $response A Response instance
  *
  * @api
  */
 public function terminate(SyfmonyRequest $request, Response $response)
 {
     $this->httpKernel->terminate(Request::createFromBase($request), $response);
 }
开发者ID:codeception,项目名称:base,代码行数:12,代码来源:Laravel5.php

示例12: buildRequest

 /**
  * Build an \Illuminate\Http\Request object
  *
  * @param string $verb
  * @param \Ratchet\ConnectionInterface $connection
  * @param \Rathcet\Wamp\Topic $topic
  * @param array $data
  * @return \Illuminate\Http\Request
  */
 protected function buildRequest($verb, Connection $connection, $topic, $data = [], $params = null)
 {
     $uri = ['protocol' => 'ws://', 'host' => $connection->WebSocket->request->getHost(), 'port' => ':' . config('twostream.websocket.port'), 'path' => '/' . trim($topic->getId(), '/') . (isset($params) ? '/' . implode('/', $params) : '')];
     $cookies = $connection->WebSocket->request->getCookies();
     array_forget($cookies, config('session.cookie'));
     // Make sure the normal Session Facade does not contain the client's Session.
     return Request::createFromBase(SymfonyRequest::create(implode($uri), strtoupper($verb), ['data' => $data], $cookies, [], [], null));
 }
开发者ID:WebDevBren,项目名称:TwoStream,代码行数:17,代码来源:Dispatcher.php

示例13: initialize

 /**
  * Initialize the Laravel framework.
  *
  * @param SymfonyRequest $request
  */
 private function initialize($request = null)
 {
     // Store a reference to the database object
     // so the database connection can be reused during tests
     $this->oldDb = null;
     if ($this->app['db'] && $this->app['db']->connection()) {
         $this->oldDb = $this->app['db'];
     }
     $this->app = $this->kernel = $this->loadApplication();
     // Set the request instance for the application,
     if (is_null($request)) {
         $appConfig = (require $this->module->config['project_dir'] . 'config/app.php');
         $request = SymfonyRequest::create($appConfig['url']);
     }
     $this->app->instance('request', Request::createFromBase($request));
     // Reset the old database after the DatabaseServiceProvider ran.
     // This way other service providers that rely on the $app['db'] entry
     // have the correct instance available.
     if ($this->oldDb) {
         $this->app['events']->listen('Illuminate\\Database\\DatabaseServiceProvider', function () {
             $this->app->singleton('db', function () {
                 return $this->oldDb;
             });
         });
     }
     $this->app->make('Illuminate\\Contracts\\Http\\Kernel')->bootstrap();
     // Record all triggered events by adding a wildcard event listener
     $this->app['events']->listen('*', function () {
         $this->triggeredEvents[] = $this->normalizeEvent($this->app['events']->firing());
     });
     if ($this->module->config['disable_middleware'] || $this->middlewareDisabled) {
         $this->app->instance('middleware.disable', true);
     }
     if ($this->module->config['disable_events'] || $this->eventsDisabled) {
         $this->mockEventDispatcher();
     }
     $this->module->setApplication($this->app);
 }
开发者ID:Marfuz,项目名称:c4t_test,代码行数:43,代码来源:Laravel5.php

示例14: makeJsonRequest

 protected function makeJsonRequest($request, $content)
 {
     $newRequest = SymphonyRequest::create($request->getUri(), $request->getMethod(), [], $request->cookie(), [], $this->transformHeadersToServerVars($request->headers->all()), $content);
     return Request::createFromBase($newRequest);
 }
开发者ID:asxer,项目名称:libsodium-laravel,代码行数:5,代码来源:EncryptService.php

示例15: dealWithRequest

 private function dealWithRequest($request)
 {
     $get = isset($request->get) ? $request->get : array();
     $post = isset($request->post) ? $request->post : array();
     $cookie = isset($request->cookie) ? $request->cookie : array();
     $server = isset($request->server) ? $request->server : array();
     $header = isset($request->header) ? $request->header : array();
     // #4 swoole 1.7.19 will no longer do urlencode on cookies by denghongcai
     if (strnatcasecmp(SWOOLE_VERSION, '1.7.19') < 0) {
         // #2 laravel结合swoole每次刷新session都会变的问题 by cong8341
         // 注:由于swoole对cookie中的特殊字符(=等)做了urlencode,导致laravel的encrypter
         //     在下次请求时接受到的payload与上一个请求响应时发出的不一致,最终导致每次请求
         //     都解出不一样的laravel_session
         foreach ($cookie as $key => $value) {
             $cookie[$key] = urldecode($value);
         }
     }
     // #5 增强与Laravel的兼容,处理特殊请求体 by denghongcai
     // swoole中header并没有包含于$request->server中,需要合并
     foreach ($header as $key => $value) {
         $header['http_' . $key] = $value;
         unset($header[$key]);
     }
     $server = array_merge($server, $header);
     // 在swoole环境下$_SERVER的所有key都为小写,需要把它们转化为大写
     foreach ($server as $key => $value) {
         $server[strtoupper($key)] = $value;
         unset($server[$key]);
     }
     // #5 增强与Laravel的兼容,处理特殊请求体 by denghongcai
     // 对于Content-Type为非application/x-www-form-urlencoded的请求体需要给
     // SymfonyRequest传入原始的Body
     $content = $request->rawContent();
     $content = empty($content) ? null : $content;
     // 创建illuminate_request
     $illuminate_request = IlluminateRequest::createFromBase(new SymfonyRequest($get, $post, array(), $cookie, array(), $server, $content));
     return $illuminate_request;
 }
开发者ID:wuxw,项目名称:swala,代码行数:38,代码来源:Server.php


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