PHP code example of starychfojtu / viewcomponent

1. Go to this page and download the library: Download starychfojtu/viewcomponent 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/ */

    

starychfojtu / viewcomponent example snippets

 
'ViewComponent\ViewComponentBundle' => ['all' => true]

# src/AppBundle/Component/MenuViewComponent



namespace AppBundle\Component;

use Starychfojtu\ViewComponentBundle\ViewComponentInterface;

class MenuViewComponent implements ViewComponentInterface
{
    public function render(): array
    {
        return [
            'links' => ['home','about','contact']
        ];
    }
}


# src/AppBundle/Component/MenuViewComponent



namespace AppBundle\SpecialComponent;

use Starychfojtu\ViewComponentBundle\ViewComponentInterface;

class MenuViewComponent implements ViewComponentInterface
{
    public function render(): array
    {
        return [
            'links' => ['home','about','contact'],
            'template' => 'AnotherMenu'
        ];
    }
}