First of all, I do not recommend embedding libraries that do not support symfony in /vendors
. Since you manage this library, put it in /src
.
Secondly, when using classes that are not a namespace (i.e., located in the root namespace), make sure that you reference them correctly, otherwise PHP will look in the current namespace (which in this case is your namespace controllers)
Thirdly, a quick and dirty solution is to simply include files from the controller correctly:
class DefaultController extends Controller { protected function includeSsrsSdk() { require_once( $this->container->getParameter( 'kernel.root_dir' ) . '/../src/ssrs/lib/Ssrs/src/SSRSReport.php' ); } public function viewAction() { $this->includeSsrsSdk(); define("UID", "xxxxxxxx"); define("PASWD", "xxxxxxxx"); define("SERVICE_URL", "http://xxx.xxx.xxx.xxx/ReportServer/"); $report = new \SSRSReport(new \Credentials(UID, PASWD), SERVICE_URL); return $this->render('myBundle:Default:view.html.twig' , array('report' => $report) ); } }
But this blocks your logic for including the library in this one controller. You can create a separate shell for the SDK that does this, or even register it as a service.
source share