drupal_lookup_path() have been remove in Drupal 8. However, I cannot find a way to achieve the same functionality. All, I'm trying to do is to provide Drupal with a path and he is going to look to see if exist, if exist is going to provide me the node id. If does not exist that path he going to give me an error or null/0.

How can I achieve this on Drupal 8?

2 Answers 2


Drupal 7:

$path .= drupal_lookup_path('alias', $path);

Drupal 8:

$alias = 

if (strcmp($alias, $path) == 0) {
  $alias = '';  // No alias was found.

$path .= $alias;

Reference Link

8 calls to drupal_lookup_path()

  • 5
    This does not apply any more. getPathAlias() have change to getAliasByPath(). Jun 11, 2015 at 18:42

In my case i got it work by using this

$path = "certainpath"; $alias = \Drupal::service('path.alias_storage')->aliasExists($path, 'en');

it will return true if path exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.