I'm trying to create an instance of an object with a path like(C:\wamp\www...)
In a new project I have this method, and I try with that to instance an object of an another project.
public function getControllerObject($class)
{
$object = null;
$class = realpath($class);
$class = str_replace('.php','',$class);
$object = new $class();
}
the variable $class have for exemple this value :
C:\wamp\www\myproject\projectBundle\Controller\DefaultController
But i get FatalErrorException: Error: Class. Class not found
I already try to put 2 backslash but it doesn't work.
Any idea?
usestatement and just create them like$controller = new IndexController();C:\wamp\[...]\Controller\DefaultController. The PHP file must be included or called by the autoloader if you want to access it.require_once(realpath($class));statement to your code, then add$object = new ClassName();. You can't create an instance of a file, you can, however, create an instance of a class definition