Question

I understand that a bundle should contain the directory structure and other conventions outlined in the best practices documentation.

I still fail to see why I should choose between installing a library as a bundle or just installing a PSR-0 compatible library "as is" in a Symfony2 installation.

For instance, I want to install the Guzzle Http Client library. Currently I have two versions to choose from:

I can see that the bundle uses the library but since I am new to Symfony2, I can't yet grasp the 'big picture'. Can someone help me out?

Was it helpful?

Solution

Using the bundle instead of the library will allow you to access the library from the ServiceContainer.

This will allow you to easily call the library; for instance in a Controller:

<?php
public function someAction(){
    // ...
    $guzzle = $this->get('guzzle.service_builder');
    // ...
}

check out http://symfony.com/doc/current/book/service_container.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top