PHP code example of webkadabra / yii2-docs-module

1. Go to this page and download the library: Download webkadabra/yii2-docs-module 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/ */

    

webkadabra / yii2-docs-module example snippets


// ...
'modules' => [
        // ...
        'docs' => [
            'class' => 'webkadabra\yii\modules\docs\Module',  
        ],
        // ...
],
// ...

// ...
'modules' => [
        // ...
        'docs' => [
            'class' => 'webkadabra\yii\modules\docs\Module',
            'layout' => '/docs',
            'on beforeAction' => function ($event) {
                /** @var yii\base\ActionEvent $event */
                Yii::$app->view->params['breadcrumbs'][] = [
                    'label' => Yii::t('app', ucfirst($event->sender->id)),
                    'url' => ['docs/docs/index'],
                ];
                $exs = explode('/', Yii::$app->request->getQueryParam('page'));
                $current = array_pop($exs);
                $path = [];
                foreach ($exs as $ex) {
                    $path[] = $ex;
                    Yii::$app->view->params['breadcrumbs'][] = [
                        'label' => ucwords(str_replace(['/', '_'], ['/', ' '], $ex)),
                        'url' => rawurldecode(\common\helpers\Url::toRoute(
                            [
                                'docs/docs/index',
                                'page' => implode('/', $path),
                            ]
                        )), 
                    ];
                }
                Yii::$app->view->params['breadcrumbs'][] = ucwords(str_replace(
                    ['/', '_'],
                    ['/', ' '],
                    $current
                ));
            },
        ],
        // ...
],
// ...

// ...
'components' => [
  // ...
    'urlManager' => [
      'rules' => [
        'docs/<page:[\w\d\/_-]*>' => 'docs/docs/index',
      ],
    ],
  ],