當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。