symfony 2.5 use ClassLoader to add Zend_pdf -
i'm working in symfony 2.5 , want use zend framework pdf (zend_pdf)
i tried classloader wrong because doesn't work (of course)...
i don't know add classloader... thought in autoload.php not know how... autoload.php, standard one:
<?php use doctrine\common\annotations\annotationregistry; use composer\autoload\classloader; /** * @var classloader $loader */ $loader = require __dir__.'/../vendor/autoload.php'; annotationregistry::registerloader(array($loader, 'loadclass')); return $loader;
i tried adding in controller this:
use symfony\component\classloader\classloader; /** * @template() */ public function pdfaction() { $loader = new classloader(); $loader->addprefix('zend', __dir__.'/vendor/zf/library'); $loader->register(); $pdf = new \zend\pdf\zend_pdf(); ....
but says:
attempted load class "zend_pdf" namespace "zend\pdf". did forget "use" statement namespace?
how solve this? thanks.
you should register new namespace it
i have follow solution connect zf library
1) zf library located @ vendor/gamma/zf/library
2) venvodor/zf/composer.json
{ "name": "gamma/zf", "type": "symfony-bundle", "autoload": { "psr-0": { "zend_": "" } }, "target-dir": "", "require": { "php": ">=5.3.3", "symfony/symfony": "~2.1" } }
3) app/autoload.php
<?php use doctrine\common\annotations\annotationregistry; $loader = include __dir__.'/../vendor/autoload.php'; $loader->add("zend_", __dir__.'/../vendor/gamma/zf/library'); set_include_path(__dir__.'/../vendor/gamma/zf/library'.path_separator.get_include_path());
4) make composer update generate new namespace
5) use @ service/controller as
<?php namespace myapp\somebundle\services; use symfony\component\dependencyinjection\containerinterface; use zend_xmlrpc_client; public function __construct(containerinterface $container, $cookiepath) { ... $this->xmlrpc = new zend_xmlrpc_client($zendurl->geturi(), $server); ... }
Comments
Post a Comment