0

I joined a PHP project in which I found path that look like this @template/file.html.twig. I would like to do a file_exist("@template/file.html.twig") but this do not resolve the full path and it return false even if the file exist.

Is there a way to resolve such a path to the real one ?

Xiidref
  • 1,456
  • 8
  • 20
  • 1
    You need to replace `@template` with its meaning first. That's not a standard PHP feature, you must be using a template library or framework. – Barmar May 19 '21 at 16:18
  • `@` represents a [Twig Namespace](https://symfony.com/doc/current/templates.html#template-namespaces), you'll need to dig into your application's configuration to find out where this namespace is registered, and which directory (or directories) it refers to. – iainn May 19 '21 at 16:46
  • 1
    It's possible that your framework has a builtin mechanism to determine if a given template exists, thus using `file_exists()` is not appropriate. For instance, I found this for [Symfony](https://stackoverflow.com/questions/16751401/check-if-template-exists-before-rendering). – Álvaro González May 19 '21 at 18:01

0 Answers0