{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/8889","labels_url":"https://api.github.com/repos/laravel/framework/issues/8889/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/8889/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/8889/events","html_url":"https://github.com/laravel/framework/issues/8889","id":80786404,"number":8889,"title":"Faster Request","user":{"login":"rkgrep","id":2423048,"avatar_url":"https://avatars.githubusercontent.com/u/2423048?v=3","gravatar_id":"","url":"https://api.github.com/users/rkgrep","html_url":"https://github.com/rkgrep","followers_url":"https://api.github.com/users/rkgrep/followers","following_url":"https://api.github.com/users/rkgrep/following{/other_user}","gists_url":"https://api.github.com/users/rkgrep/gists{/gist_id}","starred_url":"https://api.github.com/users/rkgrep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkgrep/subscriptions","organizations_url":"https://api.github.com/users/rkgrep/orgs","repos_url":"https://api.github.com/users/rkgrep/repos","events_url":"https://api.github.com/users/rkgrep/events{/privacy}","received_events_url":"https://api.github.com/users/rkgrep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-05-26T04:36:02Z","updated_at":"2015-05-29T03:59:34Z","closed_at":null,"body":"Currently Request class relies on Symfony Request - which is not bad while you use something like `$request->query->get('foo')`, but it is much slower when you use `$request->input('foo')` because it goes through at least 4 conditions and one cycle even before `array_get` which makes this handy method much slower (the benchmark is rough but it shows the difference).\r\n\r\n![4](https://cloud.githubusercontent.com/assets/2423048/7805305/9115aa10-0391-11e5-929a-4744a6b4800c.PNG)\r\n\r\nMy proposal is to make an ImmutableRequest which cannot be modified after construction and stores all data as simple arrays or internal properties.\r\n\r\nIt could be used in most applications as far as they don't need to change Request properties in runtime.\r\n\r\n````php\r\nclass ImmutableRequest implements RequestContract\r\n{\r\n//...\r\nprotected $input;\r\n\r\npublic function input($key = null, $default = null)\r\n{\r\n    return array_get($this->input, $key, $default);\r\n}\r\n//...\r\n}\r\n\r\n// ...\r\n\r\npublic function postFoo(ImmutableRequest $request)\r\n{\r\n    $request->input('foo');\r\n}\r\n\r\npublic function postBar(Request $request)\r\n{\r\n    $request->request->set('bar', 1);\r\n    //...\r\n    $request->input('bar')\r\n}\r\n````\r\n\r\nI can open a PR if you agree that this will help to improve performance"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/106676647","html_url":"https://github.com/laravel/framework/issues/8889#issuecomment-106676647","issue_url":"https://api.github.com/repos/laravel/framework/issues/8889","id":106676647,"user":{"login":"rkgrep","id":2423048,"avatar_url":"https://avatars.githubusercontent.com/u/2423048?v=3","gravatar_id":"","url":"https://api.github.com/users/rkgrep","html_url":"https://github.com/rkgrep","followers_url":"https://api.github.com/users/rkgrep/followers","following_url":"https://api.github.com/users/rkgrep/following{/other_user}","gists_url":"https://api.github.com/users/rkgrep/gists{/gist_id}","starred_url":"https://api.github.com/users/rkgrep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkgrep/subscriptions","organizations_url":"https://api.github.com/users/rkgrep/orgs","repos_url":"https://api.github.com/users/rkgrep/repos","events_url":"https://api.github.com/users/rkgrep/events{/privacy}","received_events_url":"https://api.github.com/users/rkgrep/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T03:59:34Z","updated_at":"2015-05-29T03:59:34Z","body":"@stevestock Here it is: https://github.com/nicmart/Benchmark"}}