0

I'm trying to use the DOMPDF library with the Symfony framework. I put the necessary file to include in autoload.php. When I try to use it inside an action in a controller I get the following error:

Fatal error: Class 'MyProject\ClientBundle\Controller\DOMPDF' not found in /var/www.....

I uses namespaces, this is my first line in my controller file:

namespace MyProject\ClientBundle\Controller;

The DOMPDF library doesn't use namespaces. How could I make it work?

hakre
  • 193,403
  • 52
  • 435
  • 836
user1213679
  • 259
  • 1
  • 4
  • 12

2 Answers2

1

If you are using namespaces and your library doesn't, that means that DOMPDF is avaliable in the global namespace environment. When you call some class from a some namespace, PHP uses relative namespace path by default. If you want to get access to the global namespace you should add a backslash at the start of the class namespace you are calling, e.g. use \DOMPDF. That means you are using absolute path to a namespace.

ozahorulia
  • 9,798
  • 8
  • 48
  • 72
0

Simply put a backslash in front of the classname.

Pierre
  • 874
  • 6
  • 8