1

\I heard that Laravel was made with symfony, php framework. So, I thought symfony bundle will work at Laravel, too.

IgorwFileServeBundle github

I want to install it to Laravel "5.1.*". So I edited this line at composer.json.

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "igorw/file-serve-bundle": "~1.0"
},

then I executed composer update. readme.md say I have to add it to my app's kernel.

public function registerBundles()
{
    $bundles = array(
        // ...
        new Igorw\FileServeBundle\IgorwFileServeBundle(),
        // ...
    );
    // ...
}

So I added it to my kernel.

protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \App\Http\Middleware\VerifyCsrfToken::class,
    \Igorw\FileServeBundle\IgorwFileServeBundle::class,
];

But When I save and go to my app at brower, FatalErrorException in Bundle.php line 29: Class 'Symfony\Component\DependencyInjection\ContainerAware' not found was appear.

What I'm wrong?

1
  • Symfony bundles don't work out of the box with laravel. Laravel uses components from symfony, mainly the http kernel but beyond that there's a lot of differences Commented Oct 4, 2015 at 15:56

1 Answer 1

6

Symfony and Laravel are 2 completely different frameworks. Symfony is build on top of 20+ (maybe even 30+) Symfony components (standalone libraries created by the Symfony team). These components are bound together by the framework bundle and the framework that was created is called the Symfony full-stack framework.

Some of these components are also used by Laravel. The Laravel framework is just another way of glueing these components together. Silex, another framework, is yet another way of binding these components.

Bundles is a concept from the Symfony full-stack component (HttpKernel component actually). Laravel does not use this, so you can't use any bundles in Laravel.

If you need to use a Symfony bundle, you need to have a Symfony application. Fortunately for your, Laravel has a big community as well. It's very likely that there is a Laravel package implementing the same feature for the Laravel framework.

Sign up to request clarification or add additional context in comments.

3 Comments

Symfony team has built many bundles which are mostly not dependent on each other so theoretically, you can use Symfony bundles inside Laravel but it depends.
@ClemC I disagree, nothing of the concepts in this answer are wrong or misleading for Symfony 4 or the upcoming 5.
@WouterJ Apologies, I misreaded, I delete MY misleading comment.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.