php - Symfony2 - Use a third party library (SSRS) -
maybe dumb question, i'm new symfony2 , i'm using 1 of projects.
i'd able use third party library, namely ssrsreport (an api ssrs reports).
i have put library symfony/vendor/ssrs/lib/ssrs/src.
there many classes defined here, don't need them autoloaded.
i don't know how require , call them controller.
for sure doesn't work
require_once '/vendor/ssrs/lib/ssrs/src/ssrsreport.php'; class defaultcontroller extends controller { public function viewaction() { 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) ); } } ssrsreport() , credentials() used here, 2 of many classes contained api.
first of all, don't recommend putting non-symfony-managed libraries /vendors. since you're managing library, put /src.
secondly, when using classes aren't namespace (i.e., in root namespace), make sure reference them or else php in current namespace (which, in case, controller namespace)
thirdly, quick-and-dirty solution include files controller:
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 locks logic including library 1 controller. make separate wrapper sdk this, or register service.
Comments
Post a Comment