php - SplFileObject error failed to open stream: No such file or directory -
i trying implement passbook web service in symfony2 , following passbook bundle , controller looks this
if ($form->isvalid()) { // create event ticket $pass = new eventticket("1234567890", "the beat goes on"); $pass->setbackgroundcolor('rgb(60, 65, 76)'); $pass->setlogotext('apple inc.'); // create pass structure $structure = new structure(); // add primary field $primary = new field('event', 'the beat goes on'); $primary->setlabel('event'); $structure->addprimaryfield($primary); // add secondary field $secondary = new field('location', 'moscone west'); $secondary->setlabel('location'); $structure->addsecondaryfield($secondary); // add auxiliary field $auxiliary = new field('datetime', '2013-04-15 @10:25'); $auxiliary->setlabel('date & time'); $structure->addauxiliaryfield($auxiliary); // add icon image $icon = new image('appassbundle/resources/images/icon.png', 'icon'); $pass->addimage($icon); // set pass structure $pass->setstructure($structure); // add barcode $barcode = new barcode(barcode::type_qr, 'barcodemessage'); $pass->setbarcode($barcode); // create pass factory instance $factory = new passfactory('pass.dk.mcoupons.mcoupon', '9w6x83aq63', 'ka innovation aps', '%kernel.root_dir%/resources/certificates/certificate.p12', 'hestmink09', '%kernel.root_dir%/resources/certificates/applewwdrca.pem'); $factory->setoutputpath('%kernel.root_dir%/logs/pkpass'); $factory->package($pass); //$em = $this->getdoctrine()->getentitymanager(); //$em->persist($task); //$em->flush(); echo 'pass generated '; return $this->render('apbappassbundle:default:index.html.twig'); }
but giving me error
splfileobject::__construct(appassbundle/resources/images/icon.png): failed open stream: no such file or directory 500 internal server error - runtimeexception
i have tried different ways give path failed. here hierarchy or folder structure images stored
try
$icon = new image('%kernel.root_dir%/appassbundle/resources/images/icon.png', 'icon');
or maybe:
$iconpath = $this->get('kernel')->getrootdir().'/appassbundle/resources/images/icon.png'; $icon = new image($iconpath, 'icon');
or similar, don't see whole structure of project.
Comments
Post a Comment