0

I need to load an external AppKernel file inside my symfony application. This external AppKernel is responsible for handling requests. The problem is, It can't autoload the classes/bundles that the external application uses. Is there a way to use an external symfony 2 application inside another application?

This is what I tried so far:

    require_once '/path/to/external/AppKernel.php';

    $class = 'Namespace\AppKernel';
    $path = realpath(dirname('/path/to/external/AppKernel.php'));

    // I tried this, but this does not work...
    $loader = require_once $path . '/autoload.php';

     /**
     * @var HttpKernel $kernel
     */
    $kernel = new $class('dev', true);

    $response = $kernel->handle($request);

Steffen

EDIT

I've tried the following also, the Kernel is loaded correctly, but I get a 404 on every valid request. I think i'm somewhat closer, someone any tips?

// Get Class Loader
$loader = \ComposerAutoloaderInitea05f7b71e624f9c387fc10b8508d099::getLoader();

// Add src folder to fallback dirs
$loader->add(null, array(realpath($path . '/../src')));

/**
 * @var Kernel $kernel
 */
$kernel = new $class('prod', true);
$kernel->loadClassCache();

$response = $kernel->handle($request);
$response->send();

$kernel->terminate($request, $response);

return $response;
2
  • I'd also like to know this, did you figure out how to instantiate another AppKernel within a Symfony installation?
    – Mirage
    Mar 27, 2014 at 14:55
  • @MelvinValster Here a link to provide you with some more info: stackoverflow.com/questions/20324414/… Apr 3, 2014 at 15:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.