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


PHP Request::create方法代码示例

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


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

示例1: getTraces

 /**
  * Returns the routing traces associated to the given request.
  *
  * @param RequestDataCollector $request
  * @param string               $method
  *
  * @return array
  */
 private function getTraces(RequestDataCollector $request, $method)
 {
     $traceRequest = Request::create($request->getPathInfo(), $request->getRequestServer()->get('REQUEST_METHOD'), $request->getRequestAttributes()->all(), $request->getRequestCookies()->all(), array(), $request->getRequestServer()->all());
     $context = $this->matcher->getContext();
     $context->setMethod($method);
     $matcher = new TraceableUrlMatcher($this->routes, $context);
     return $matcher->getTracesForRequest($traceRequest);
 }
开发者ID:raphydev,项目名称:onep,代码行数:16,代码来源:RouterController.php

示例2: analyse

 public function analyse()
 {
     $query = Input::get('q');
     $analysisData = new stdClass();
     $analysisData->keyword = $query;
     $analysisData->posts = array();
     $analysisData->tools = array('all');
     $postsRetrievers = array(new FacebookPostsRetriever(), new TwitterPostsRetriever());
     foreach ($postsRetrievers as $postsRetriever) {
         $posts = $postsRetriever->retrieve($query, null);
         $analysisData->posts = array_merge($analysisData->posts, $posts);
     }
     $analysisDataJSON = json_encode($analysisData);
     //        $response = Unirest::post("http://service/analyzer",
     //			array( "Accept" => "application/json" ),
     //			array('query' => $analysisDataJSON)
     //        );
     $request = Request::create('/service/analyzer', 'POST', array('query' => $analysisDataJSON));
     Request::replace($request->input());
     $response = Route::dispatch($request)->getContent();
     //		$analysisResult = json_decode($response->raw_body);
     $analysisResult = json_decode($response);
     foreach ($analysisResult->posts as $post) {
         foreach ($analysisData->posts as $postData) {
             if ($postData['id'] == $post->id) {
                 $post->data = $postData;
                 break;
             }
         }
     }
     return View::make('AnalysisResult')->with('analysisResult', $analysisResult);
 }
开发者ID:farhan4648gul,项目名称:sentian,代码行数:32,代码来源:Analyser.php

示例3: testAbsoluteLinkShouldAddRootUriFromRequest

 public function testAbsoluteLinkShouldAddRootUriFromRequest()
 {
     $helper = new UrlHelper();
     $request = Request::create(false, 'localhost', '/webroot/test', '/webroot');
     $this->assertEquals('http://localhost/webroot/page', $helper->absoluteLink('/page', $request));
     $request = Request::create(true, 'localhost', '/webroot/test', '/webroot');
     $this->assertEquals('https://localhost/webroot/page', $helper->absoluteLink('/page', $request));
 }
开发者ID:holger,项目名称:yoshi,代码行数:8,代码来源:UrlHelperTest.php

示例4: call

 /**
  * Call the given URI and return a Response.
  *
  * @param  string $uri
  *
  * @return \Illuminate\Http\Response
  */
 protected function call($uri)
 {
     $request = Request::create($uri, 'GET');
     $kernel = $this->app->make(HttpKernel::class);
     $response = $kernel->handle($request);
     $kernel->terminate($request, $response);
     return $response;
 }
开发者ID:alcodo,项目名称:async-css,代码行数:15,代码来源:Rebuild.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $request = Request::create('/api/blocknotify', 'GET', array('secret' => !$this->option('secret') ? Config::get('bitcoin.callback_secret') : $this->option('secret'), 'blockhash' => $this->option('blockhash')));
     Request::replace($request->input());
     $response = Route::dispatch($request)->getContent();
     if ($this->option('debug')) {
         $this->info($response);
     }
 }
开发者ID:denpamusic,项目名称:EzBitcoin-Api-Wallet,代码行数:14,代码来源:ApiBlocknotify.php

示例6: getInstance

 public static function getInstance(array $config = array())
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
         self::$_instance->config = array('charset' => 'utf-8', 'content_type' => 'text/html', 'database' => array('models' => BASE_PATH . '/models/', 'engine' => 'sqlite3', 'db_name' => BASE_PATH . '/test.db'), 'static_url' => '/static', 'xhtml_tags' => false);
         Request::create();
     }
     date_default_timezone_set('Australia/ACT');
     return self::$_instance;
 }
开发者ID:plasticine,项目名称:rivet,代码行数:10,代码来源:Rivet.php

示例7: ruta

 /**
  * Metodo para crear request entre controladores
  * 
  * @param type $url Metodo destino
  * @param type $method Metodo de envio (GET o POST)
  * @param type $data Arreglo de datos
  * @param type $json Si el retorno es json o array
  * @return type JSON o ARRAY
  */
 public static function ruta($url, $method, $data, $json = true)
 {
     //Datos enviados, vector
     Input::replace($data);
     //Crea Request via GET o POST
     $request = Request::create($url, $method);
     //Obtener response
     $response = Route::dispatch($request);
     //Solo contenido, en formato json
     $content = $response->getContent();
     if ($json) {
         //Retorna formato JSON
         return $content;
     } else {
         //Retorna un arreglo
         return json_decode($content);
     }
 }
开发者ID:lueimg,项目名称:activista,代码行数:27,代码来源:Helpers.php

示例8: release

 public function release($url, $method = 'GET', $input, $no_json)
 {
     // Store the original input of the request
     $originalInput = \Request::input();
     // Create request to the API, adding the no-json parameter, since it's an internal request
     $request = \Request::create($url, $method);
     // Replace the input with the request instance input
     \Request::replace($input);
     // Fetch the response
     if ($no_json) {
         $content = \Route::dispatch($request)->getContent();
         $result = json_decode($content, 1);
     } else {
         $result = \Route::dispatch($request)->getContent();
     }
     // Replace the input again with the original request input.
     \Request::replace($originalInput);
     return $result;
 }
开发者ID:kfuchs,项目名称:Laravel-5-Bootstrat-REST-API,代码行数:19,代码来源:InternalDispatcher.php

示例9: Create

    public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null) {
        if (empty($p_sessionId)) {
            throw new SessionIdNotSet();
        }

        $session = new Session($p_sessionId);
        if (!$session->exists()) {
            $sessionParams = array('start_time'=>strftime("%Y-%m-%d %T"));
            if (!empty($p_userId)) {
                $sessionParams['user_id'] = $p_userId;
            }
            $session->create($sessionParams);
        }
        $sessionUserId = $session->getUserId();
        if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) {
            throw new InvalidUserId();
        }

        $requestObject = new RequestObject($p_objectId);
        if (!$requestObject->exists()) {
            if (empty($p_objectTypeId)) {
                throw new ObjectTypeIdNotSet();
            }
            $requestObject->create(array('object_type_id'=>$p_objectTypeId));
            $p_objectId = $requestObject->getObjectId();
        } elseif (empty($p_objectId)) {
            throw new ObjectIdNotSet();
        }

        $request = new Request($p_sessionId, $p_objectId);
        if (!$request->exists()) {
            $request->create();
        }
        if (!$request->isInStats()) {
        	$requestStats = new RequestStats($p_objectId);
        	if (!$requestStats->exists()) {
        		$requestStats->create();
        	}
        	$requestStats->incrementRequestCount();
            $request->setLastStatsUpdate();
        }
    }
开发者ID:nistormihai,项目名称:Newscoop,代码行数:42,代码来源:SessionRequest.php

示例10: testUnhandledForms

 /**
  * Forms must never accept empty request
  */
 public function testUnhandledForms()
 {
     // get form kernel
     $forms = app('Lavender\\Contracts\\Form\\Kernel');
     foreach ($forms->all() as $id => $class) {
         $form = form($id)->resolve();
         // form must always resolve correctly
         $this->assertInstanceOf($class, $form);
         // create empty request
         $request = Request::create('/', 'POST', []);
         // create a form request
         $form_request = app('Lavender\\Http\\FormRequest');
         // set the current request
         $form_request->setRequest($request);
         // handle the form request
         $result = form($id)->handle($form_request);
         // empty request must always fail
         $this->assertEquals(false, $result, "Unhandled form \"{$id}\"");
     }
 }
开发者ID:BryceHappy,项目名称:lavender,代码行数:23,代码来源:LavenderTest.php

示例11: UpdateStats

 /**
  * Writes the statistics (when article read).
  *
  * @param int $p_sessionId
  *      used for not writing the stats multiple times
  * @param int $p_objectId
  *      the article object whose stats shall be updated
  * @return bool
  */
 public static function UpdateStats($p_sessionId, $p_objectId)
 {
     if (!$p_sessionId || !$p_objectId) {
         return false;
     }
     $request = new Request($p_sessionId, $p_objectId);
     if (!$request->exists()) {
         $request->create();
     }
     if (!$request->isInStats()) {
         $requestStats = new RequestStats($p_objectId);
         if (!$requestStats->exists()) {
             $requestStats->create();
         }
         $requestStats->incrementRequestCount();
         $request->setLastStatsUpdate();
         return true;
     }
     return false;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:29,代码来源:SessionRequest.php

示例12: testManyActivitiesCanBeAddedToUsers

 public function testManyActivitiesCanBeAddedToUsers()
 {
     factory(App\Group::class, 4)->create()->each(function ($g) {
         for ($i = 0; $i < 5; $i++) {
             $g->users()->save(factory(App\User::class)->make(), ['role' => 'member']);
         }
         $g->users()->save(factory(App\User::class)->make(), ['role' => 'leader']);
     });
     factory(App\Activity::class, 5)->create();
     $group = Group::find(1);
     $activity = Activity::find(1);
     $stuff = array('activityId' => $activity->id, 'group' => $group->id);
     foreach ($group->users as $user) {
         $stuff[$user->id] = 'true';
     }
     $request = Request::create('/', 'POST', $stuff);
     $this->controller->addMany($request);
     foreach ($group->users as $user) {
         $this->seeInDatabase('activity_user', ['activity_id' => $activity->id, 'user_id' => $user->id]);
     }
 }
开发者ID:partio-scout,项目名称:kokous_backend,代码行数:21,代码来源:UserActivityControllerTest.php

示例13: testConstructors

 public function testConstructors()
 {
     $request1 = Request::create('http://example.com', 'POST', ['foo' => 'bar']);
     $this->assertEquals('example.com', $request1->getHeaderLine('Host'));
     $this->assertEquals(['foo' => 'bar'], $request1->getParsedBody());
     $request2 = Request::create('http://example.com', 'GET', ['foo' => 'bar']);
     $this->assertEquals(['foo' => 'bar'], $request2->getQueryParams());
     $_SERVER = ['REQUEST_URI' => 'http://example.com', 'REQUEST_METHOD' => 'POST'];
     $_POST = ['foo' => 'bar'];
     $_GET = ['baz' => 'foobar'];
     $_COOKIE = ['bar' => 'bazbar'];
     $_FILES = ['form' => ['files' => ['tmp_name' => ['foo', 'bar'], 'name' => ['foo', 'bar'], 'size' => [52, 16], 'type' => ['baz', 'foobar'], 'error' => [0, 0]]]];
     $request3 = Request::createGlobal();
     $this->assertEquals('example.com', $request3->getHeaderLine('Host'));
     $this->assertEquals('POST', $request3->getMethod());
     $this->assertEquals(['foo' => 'bar'], $request3->getParsedBody());
     $this->assertEquals(['baz' => 'foobar'], $request3->getQueryParams());
     $this->assertEquals(['bar' => 'bazbar'], $request3->getCookieParams());
     $this->assertEquals($_SERVER, $request3->getServerParams());
     $this->assertArrayHasKey('form', $request3->getUploadedFiles());
     $this->assertCount(2, $request3->getUploadedFiles()['form']['files']);
     $this->assertInstanceOf('Jivoo\\Http\\Message\\UploadedFile', $request3->getUploadedFiles()['form']['files'][0]);
     $this->assertInstanceOf('Jivoo\\Http\\Message\\UploadedFile', $request3->getUploadedFiles()['form']['files'][1]);
 }
开发者ID:jivoo,项目名称:http,代码行数:24,代码来源:RequestTest.php

示例14: function

|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::group(['middleware' => ['api', 'web']], function ($account) {
    Route::get('/', function () {
        return 'Welcome to application';
    });
    //Route::get('/', function(){
    //	return redirect('/home');
    //});
    Route::get('/posts', function () {
        $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkb21haW4iOiJ0cmF2ZWwuY29tIiwic3ViIjoxLCJpc3MiOiJodHRwOlwvXC90cmF2ZWwuY29tXC9hcGlcL3YxXC9hdXRoZW50aWNhdGUiLCJpYXQiOjE0NTU2OTM2MDcsImV4cCI6MTQ1NTY5NzIwNywibmJmIjoxNDU1NjkzNjA3LCJqdGkiOiI3NTM0M2YzYTEyYTg1NGI2ZmI5Yjc0MWY2ZDFhYzQ1ZiJ9.3nGMHHXALcOGKPqiiuKqrAmxaJnUQasg1HX3pfYGZyA';
        $request = Request::create(Request::root() . '/api/v1/posts', 'GET', ['token' => $token]);
        $response = Route::dispatch($request)->getData();
        $result = json_decode(json_encode($response), true);
        echo '<pre>';
        print_r($result);
        //return $result;
    });
});
Route::group(['prefix' => 'api/v1', 'middleware' => ['cors', 'api.jwt']], function () {
    Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
    Route::post('authenticate', 'AuthenticateController@authenticate');
    Route::get('authenticate/user', 'AuthenticateController@getAuthenticatedUser');
    Route::get('refresh_token', 'AuthenticateController@refresh_token');
    // Api calls
    Route::resource('posts', 'Api\\V1\\postsController');
    Route::get('my_posts', 'Api\\V1\\postsController@getUserPosts');
开发者ID:ganeshkanawade,项目名称:laravel-setup,代码行数:31,代码来源:routes.php

示例15: request

 /**
  * http request wrapper
  * @param $url
  * @param $method
  * @param $parameters
  * @return \Henter\WeChat\Response
  */
 function request($url, $method, $parameters)
 {
     return Request::create(array('url' => $url, 'method' => $method, 'headers' => array('user-agent' => $this->user_agent), 'form' => $parameters, 'timeout' => $this->timeout))->send();
 }
开发者ID:henter,项目名称:wechat-oauth,代码行数:11,代码来源:OAuth.php


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