nyx-solutions/yii2-nyx-robots

Yii2 Robots.txt Generator Module

5.0.0 2022-06-02 14:55 UTC

This package is auto-updated.

Last update: 2024-11-30 02:39:01 UTC


README

Yii2 Module for automatically generating the robots.txt file.

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require --prefer-dist "nyx-solutions/yii2-nyx-robots" "*"

or add

"nyx-solutions/yii2-nyx-robots": "*"

to the require section of your application's composer.json file.

Usage

  • Configure the cache component of your application's configuration file, for example:
'components' => [
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
]
  • Add a new module in modules section of your application's configuration file, for example:
'modules' => [
    'robots' => [
        'class' => 'nyx\modules\robots\Module',
        'settings' => [
            'disallowAllRobots' => false,
            'allowAllRobots'    => false,
            'useSitemap'        => true,
            'sitemapFile'       => '/sitemap.xml',
            'robots'            => [],
            'allowRules'        => [
                'all' => [
                    '/uploads'
                ]
            ],
            'disallowRules'     => [
                'all' => [
                    '/assets'
                ]
            ]
        ]
    ]
]
  • Add a new rule for urlManager of your application's configuration file, for example:
'urlManager' => [
    'rules' => [
        ['pattern' => 'robots', 'route' => 'robots/default/index', 'suffix' => '.txt'],
    ]
]

License

yii2-nyx-robots is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

Yii2