Skip to content

MelisCmsSiteRobot

Per-domain robots.txt editing and dynamic serving from the back-office. Package melisplatform/melis-cms-site-robot.

Purpose

MelisCmsSiteRobot lets you manage the robots.txt of each site domain from the back-office and serves it dynamically at https://<domain>/robots.txt — straight from the database, with no static file to maintain. Changes take effect immediately after saving. The robots text is stored one row per domain in a dedicated table; no per-page or per-language variant exists.

Enable it

Add to config/melis.module.load.php:

php
return [
    'MelisCmsSiteRobot',
];

Dependencies: melis-core and melis-cms (^5.2). The module is dbdeploy: true, so its table is created automatically. It reuses table gateways provided by melis-engine at runtime.

Key services

The module registers no service of its own. The controller consumes existing engine services:

Service aliasRole
MelisEngineTableRobotTable gateway over melis_cms_domain_robots — reads and writes the robot_text by domain.
MelisEngineTableSiteDomainFeeds the list of site domains (sdom_id, site_label, sdom_domain) for the back-office tool.

Backoffice

Registered under CMS tools in the back-office left menu as Site robots (server icon). The tool shows a list of the platform's site domains — one row per domain. There is no Add or Delete action; you only edit existing domain entries.

Clicking Edit on a domain opens a modal with the domain name (read-only) and a large textarea holding the robots.txt content for that domain. Saving performs an upsert into melis_cms_domain_robots (the row is created on first save if absent).

ControllerClass
ToolSiteRobotMelisCmsSiteRobot\Controller\ToolSiteRobotController

Key actions:

ActionPurpose
toolContainerActionRenders the tool layout.
getSiteRobotDataActionJSON feed for the domains datatable.
toolContentTableActionEditActionThe Edit button per row.
toolModalContentActionEdit modal — domain + robot_text textarea (form key site_robot_form).
saveSiteRobotActionUpsert into melis_cms_domain_robots.
toolSiteRobotContentFiltersSitesActionSite filter in the datatable filter bar.

Listener

MelisCmsSiteRobotFlashMessengerListener forwards save results to the core flash-messenger so success/error messages appear in the back-office.

Front office

A public route in config/module.config.php (melis-cms-site-robot-special-urls) maps /robots.txt to ToolSiteRobotController::toolRobotsTxtAction. The action looks up melis_cms_domain_robots by the requesting host and outputs the stored robot_text.

RouteHandlerResult
/robots.txtToolSiteRobotController::toolRobotsTxtActionServes the robot_text stored for the requesting domain.

Database tables

TableHolds
melis_cms_domain_robotsOne robots.txt entry per domain: robot_id (PK), robot_site_domain, robot_text.

Example

Read or serve the robots text for a domain from your own code:

php
// List domains for the back-office tool:
$domains = $sm->get('MelisEngineTableSiteDomain')
              ->getData($search, $cols, $colOrder, $dir, $start, $len)->toArray();

// Get the robots.txt for a specific domain:
$robot = (array) $sm->get('MelisEngineTableRobot')
                    ->getEntryByField('robot_site_domain', $domainName)->current();
echo $robot['robot_text'] ?? '';

Key files

ConcernPath
Routes (back-office + /robots.txt)vendor/melisplatform/melis-cms-site-robot/config/module.config.php
Back-office tools treevendor/melisplatform/melis-cms-site-robot/config/app.interface.php
Tool datatable & edit formvendor/melisplatform/melis-cms-site-robot/config/app.tools.php
Controller (all actions)vendor/melisplatform/melis-cms-site-robot/src/Controller/ToolSiteRobotController.php
Flash-messenger listenervendor/melisplatform/melis-cms-site-robot/src/Listener/MelisCmsSiteRobotFlashMessengerListener.php
Install SQLvendor/melisplatform/melis-cms-site-robot/install/

See also: Module reference, melis-cms, melis-core