Get the current page URI programmatically on Drupal 8?

drupal 8 uri path

<?php 

// To get the base url
$host = \Drupal::request()->getSchemeAndHttpHost();
//https://www.local.com

$current_url = Url::fromRoute('<current>');
$path = $current_url->toString();

//Examples for the page /en/user/login:
$current_url->toString();    // /en/user/login
$current_url->getInternalPath();    // user/login
$path = $current_url->getRouteName();   // <current>

//Drupal syntax.
$path = \Drupal::request()->attributes->get('_system_path');

// Include a query string
$current_uri = \Drupal::request()->getRequestUri();

// For the current raw path (the un-aliased Drupal path):
$current_path = \Drupal::service('path.current')->getPath();
$result = \Drupal::service('path_alias.manager')->getAliasByPath($current_path);

//Get the url of the request for displayed on the browser.
$page = \Drupal::request()->getRequestUri();

?>

 

Comment

//To get the current path Route
$current_path = \Drupal::service('path.current')->getPath();
$getRoute = \Drupal::routeMatch()->getRouteName();

Instagram Without API

Could not reach Instagram server