php - Getting error in add Bundle in Vendor Folder in Symfony2 -
bundle name : open tok ( downloaded github )
i put folder in vendor folder of symfony( project name\vendor\opentok\opentok\and files , folders here )
in appkernel.php
<?php use symfony\component\httpkernel\kernel; use symfony\component\config\loader\loaderinterface; class appkernel extends kernel { public function registerbundles() { $bundles = array( new symfony\bundle\frameworkbundle\frameworkbundle(), new symfony\bundle\securitybundle\securitybundle(), new symfony\bundle\twigbundle\twigbundle(), new symfony\bundle\monologbundle\monologbundle(), new symfony\bundle\swiftmailerbundle\swiftmailerbundle(), new opentokbundle\opentokbundle(), new doctrine\bundle\doctrinebundle\doctrinebundle(), new sensio\bundle\frameworkextrabundle\sensioframeworkextrabundle(), new adminbundle\adminbundle(), new sitebundle\sitebundle(), new wsbundle\wsbundle(), ); if (in_array($this->getenvironment(), array('dev', 'test'), true)) { $bundles[] = new symfony\bundle\debugbundle\debugbundle(); $bundles[] = new symfony\bundle\webprofilerbundle\webprofilerbundle(); $bundles[] = new sensio\bundle\distributionbundle\sensiodistributionbundle(); $bundles[] = new sensio\bundle\generatorbundle\sensiogeneratorbundle(); } return $bundles; } public function registercontainerconfiguration(loaderinterface $loader) { $loader->load($this->getrootdir().'/config/config_'.$this->getenvironment().'.yml'); } }
in app\autoload.php
<?php use doctrine\common\annotations\annotationregistry; use composer\autoload\classloader; /** * @var classloader $loader */ $loader = require __dir__.'/../vendor/autoload.php'; annotationregistry::registerloader(array($loader, 'loadclass')); $loader->add('opentok' , __dir__.'/..vendor/opentok'); return $loader; ?>
composer.json
"require": { "php": ">=5.3.9", "symfony/symfony": "2.8.*", "doctrine/orm": "^2.4.8", "doctrine/doctrine-bundle": "~1.4", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "~2.0", "opentok/opentok": "dev-master" },
this above code gives me error :
fatal error: class 'opentokbundle\opentokbundle' not found
now how can use opentok bundle in other files ? please me. new symfony
your issue due slash.
should $loader->add('opentok' => __dir__.'/../vendor/opentok');
in other line (although i'm not sure actual path correct).
that being said should download , manage package using composer has dependencies won't included downloading repository.
to this:
- delete
$loader->add('opentok' => __dir__.'/..vendor/opentok');
line autoload - add
"opentok/opentok": "^2.3.2"
or version want download "require" key in composer.json - run
composer update opentok/opentok
.
the package , classes should available in application and, when require newer version, can manage through composer rather needing download package hand (along dependencies).
Comments
Post a Comment