Drupal 8 Get URL from Request code example
Example 1: drupal 8 get url query parameters
// URL query parameter.
\Drupal::request()->query->get('keys');
\Drupal::request()->query->all()
Example 2: drupal 8 get site base url
$host = \Drupal::request()->getSchemeAndHttpHost();