Change record status: 
Introduced in branch: 

As of Drupal 8, the core request handling logic has been replaced with Symfony2's HttpKernel, HttpFoundation, and related libraries. This primarily applies to module developers, but has far reaching implications for the entire system.

Of particular note:

The PHP superglobals for $_GET, $_POST, and $_SERVER are deprecated and should not be used, ever. Instead, an instance of the Symfony HttpFoundation\Request class is created during bootstrap and stored in the request() function. Module developers should access that object for any and all information about the HTTP request. (Note: The request function will be removed once that object is accessible via the Dependency Injection Container.)


$page = isset($_GET['page']) ? $_GET['page'] : 0;


$page = Drupal::service('request')->query->get('page', 0);

See the Request object documentation for more details.

menu_execute_active_handler() has been removed in favor of HttpKernel. In cases where modules need to simulate a new request, they should now create a new request object and issue a subrequest call against the kernel object.

Actual example from comment_permalink():


// Set $_GET['q'] and $_GET['page'] ourselves so that the node callback
// behaves as it would when visiting the page directly.
$_GET['q'] = 'node/' . $node->nid;
$_GET['page'] = $page;

// Return the node view.
return menu_execute_active_handler('node/' . $node->nid, FALSE);


$request = Drupal::service('request');
$subrequest = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
$subrequest->query->set('page', $page);
// @todo: Convert the pager to use the request object.
$_GET['page'] = $page;
return Drupal::service('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);

Additional implications are noted in separate change notices.

As in Drupal 7, you should not use $_GET['q'], you should use current_path(). Also see [#1659562].

Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other updates done


Artusamak’s picture

Note that the request service is now called 'request_stack' and that you need to fetch the current request differently:

    $request = Drupal::service('request_stack');
    $current_request = $request->getCurrentRequest();
    $subrequest = Request::create('/node/' . $node->nid, 'GET', $current_request->query->all(),$current_request->cookies->all(), array(), $current_request->server->all());

Twitter account: @Artusamak

gaja_daran’s picture

We can get directly using this in D8

$page = \Drupal::request()->query->get('page', 0);