PHP code example of symfonette / class-named-services

1. Go to this page and download the library: Download symfonette/class-named-services 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/ */

    

symfonette / class-named-services example snippets


use Symfonette\ClassNamedServices\ContainerBuilderConfigurator;
use Symfony\Component\DependencyInjection\ContainerBuilder;

$builder = new ContainerBuilder();
$configurator = new ContainerBuilderConfigurator();

$configurator->configure($builder);


use Symfonette\ClassNamedServices\Bundle\ClassNamedServiceBundle;
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        return [
            // ...
            new ClassNamedServiceBundle,
            // ...
        ];
    }
}

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class ContactController extends Controller
{
    public function formAction()
    {
        $validator = $this->get(Validator::class);
        // ...
    }
}