PHP code example of yiisoft / widget

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

    

yiisoft / widget example snippets


final class MyWidget extends \Yiisoft\Widget\Widget
{
    public function render(): string
    {
        return 'My first widget.'.
    }
}

<?= MyWidget::widget() 

/**
 * @var \Psr\Container\ContainerInterface $container
 */
 
$widgetDefaults = [
    MyWidget::class => [
        'withNumber()' => [42],
    ],
];

\Yiisoft\Widget\WidgetFactory::initialize($container, $widgetDefaults);