PHP code example of itstructure / yii2-sitemap-generator

1. Go to this page and download the library: Download itstructure/yii2-sitemap-generator 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/ */

    

itstructure / yii2-sitemap-generator example snippets


return [
    'controllerMap' => [
        'sitemap' => [
            'class' => 'Itstructure\Sitemap\SitemapController',
            'baseUrl' => 'https://example.com',
            'modelsPath' => '@console/models/sitemap', // Sitemap-data models directory
            'modelsNamespace' => 'console\models\sitemap', // Namespace in [[modelsPath]] files
            'savePathAlias' => '@frontend/web', // Where would be placed the generated sitemap-files
            'sitemapFileName' => 'sitemap.xml', // Name of main sitemap-file in [[savePathAlias]] directory
        ],
    ],
];

'components' => [
    // fix console create url
    'urlManager' => [
        'baseUrl' => 'http://example.com',
    ],
],

'components' => [
    // fix console create url
    'urlManager' => [
        'baseUrl' => 'http://example.local',
    ],
],

// get config of urlManager from frontend for correctly create urls in console app
$frontend = 'urlManager'],
    ],
];

// ...

// Merge frontend urlManager config with console application main config
return yii\helpers\ArrayHelper::merge($frontendUrlManager, [
    'id' => 'app-console',
    // ...
];
code
php ./init
code
php ./yii sitemap