PHP code example of vanio / vanio-di-extra-bundle

1. Go to this page and download the library: Download vanio/vanio-di-extra-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vanio / vanio-di-extra-bundle example snippets



namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Translation\TranslatorInterface;
use Vanio\DiExtraBundle\Controller;
use Vanio\DiExtraBundle\DependencyInjection\Metadata\Inject;

class HelloController extends Controller
{
    /**
     * @var TranslatorInterface
     * @Inject
     */
    public $translator;
    
    /**
     * @Route("/hello", name="app_hello")
     * @Template
     */
    public function helloAction(): array
    {
        return ['message' => $this->translator->trans('Hello world!')];
    }
}

/**
 * @Inject("translator")
 */
public $translator;

/**
 * @Inject("translator", 

/**
 * @var TranslatorInterface|null
 * @Inject
 */
public $translator;

/**
 * @Inject("%kernel.cache_dir%/app")
 */
public $cacheDirectory;

// app/AppKernel.php
// ...

use Vanio\DiExtraBundle\DependencyInjection\Container;

class AppKernel extends Kernel
{
    // ...

    public function registerBundles(): array
    {
        $bundles = [
            // ...
            new Vanio\DiExtraBundle\VanioDiExtraBundle,
        ];

        // ...
    }

    public function getContainerBaseClass(): string
    {
        return Container::class;
    }
}