sonata-project/block-bundle
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/collections | 2.2.2 | - | MIT | prod dev | |
doctrine/common | 3.4.4 | - | MIT | prod dev | |
psr/container | 2.0.2 | 3.55 kB | MIT | prod dev | |
psr/log | 3.0.0 | 6.77 kB | MIT | prod dev | |
sonata-project/form-extensions | 2.4.0 | - | MIT | prod | |
symfony/asset | v7.1.0 | - | MIT | prod dev | |
symfony/config | v7.1.0 | - | MIT | prod dev | |
symfony/console | v7.1.0 | - | MIT | prod dev | |
symfony/dependency-injection | v7.1.0 | - | MIT | prod dev | |
symfony/error-handler | v7.1.0 | - | MIT | prod dev | |
symfony/event-dispatcher | v7.1.0 | - | MIT | prod dev | |
symfony/event-dispatcher-contracts | v3.5.0 | - | MIT | prod dev | |
symfony/form | v7.1.0 | - | MIT | prod dev | |
symfony/framework-bundle | v7.1.0 | - | MIT | prod dev | |
symfony/http-foundation | v7.1.0 | - | MIT | prod dev | |
symfony/http-kernel | v7.1.0 | - | MIT | prod dev | |
symfony/options-resolver | v7.1.0 | - | MIT | prod | |
symfony/twig-bundle | v7.1.0 | - | MIT | prod dev | |
symfony/validator | v7.1.0 | - | MIT | prod dev | |
twig/twig | v3.10.3 | - | BSD-3-Clause | prod dev |
The Sonata Block Bundle is a highly useful component of the Sonata Project, specifically designed for the Symfony framework. This bundle enables users to manage blocks, a crucial feature in web applications for handling sections of a web page. By leveraging the power of the Sonata Block Bundle, web developers can efficiently manage and customize the website's structure, including the banner, footer, sidebar, and other parts of a web page, simplifying the overall website development process.
Usage of the Sonata Block Bundle first requires installation. The most common way to add this beneficial bundle to your Symfony project is by using Composer, a tool for dependency management in PHP. To install the Sonata Block Bundle, run composer require sonata-project/block-bundle
in your project terminal.
The official and practical usage instructions can be found in the documentation, but practically, it's about defining 'blocks' in your Symfony application that represent different parts of your site.
For instance, you can define a block as follows:
namespace App\Block;
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Twig\Environment;
class MyCustomBlock extends AbstractBlockService
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'template' => 'blocks/my_custom_block.html.twig',
));
}
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
// render the block
return $this->renderResponse($blockContext->getTemplate(), array(
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings()
), $response);
}
}
This code defines a new block with a related Twig template. This block can then be rendered in any Symfony controller or Twig template.
For further information and document reference, the comprehensive documentation of Sonata Block Bundle is hosted on the official Sonata Project website. The documentation provides a step-by-step guide to effectively utilize the bundle, including installation, configuration, and other common functionalities. Visit SonataBlockBundle documentation for a detailed explanation and various examples on how to maximize the potential of this bundle in your Symfony project.