Aaska Patel Aaska Patel - 1 year ago 169
PHP Question

Getting error in add Bundle in Vendor Folder in Symfony2

Bundle Name : Open tok ( i downloaded it from github )

i put that folder in Vendor Folder of Symfony( project name\vendor\OpenTok\OpenTok\and all files and folders here )

in AppKernel.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)

in app\autoload.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;



"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 i use opentok Bundle in my all other files ? Please help me. I am new to symfony

Answer Source

Your issue is due to the slash.
It should be $loader->add('OpenTok' => __DIR__.'/../vendor/OpenTok'); as in the other line (although I'm not sure the actual path would be correct).

That being said you should actually download and manage the package using composer as it has dependencies that won't be included by just downloading the repository.

To do this:

  1. Delete the $loader->add('OpenTok' => __DIR__.'/..vendor/OpenTok'); line from your autoload
  2. Add "opentok/opentok": "^2.3.2" or the version you want to download to your "require" key in your composer.json
  3. Run composer update opentok/opentok.

The package and classes should now be available in your application and, when you require a newer version, you can manage it all through composer rather than needing to download the package by hand (along with all dependencies).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download