Skip to content

feat(setup): allow alternative context key instead of 'web'#16906

Open
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Ibochkarev:feat/context-web-key-14462
Open

feat(setup): allow alternative context key instead of 'web'#16906
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Ibochkarev:feat/context-web-key-14462

Conversation

@Ibochkarev
Copy link
Collaborator

What does it do?

Adds support for specifying a custom web context key during MODX installation instead of the default web. Changes include:

  • CLI installer (cli-install.php): New context_web_key prompt with validation (alphanumeric + underscore, forbids mgr and root)
  • Web installer (contexts.php, contexts.tpl): New input field for context key with validation and error display
  • Config (modinstallrunner.class.php): New writeContextConfig() method that writes config.context.php to the web root with the chosen context key
  • Database (new.install.php): When a custom key is used, renames the web context and updates related tables (modContextSetting, modContextResource, modAccessContext, modResource)
  • Default settings (modinstallrequest, modinstallclirequest): context_web_key defaults to web

The index.php already reads config.context.php when present (fallback to web if missing).

Why is it needed?

Allows users to install MODX with a custom front-end context key (e.g. site, frontend) instead of requiring web. Useful for multi-site setups, security through obscurity, or naming conventions.

How to test

CLI install:

php setup/cli-install.php --context_web_key=site
# Or: php setup/cli-install.php (prompt will ask for context key, default: web)

Web install:

  1. Run setup wizard
  2. On the contexts step, enter a custom key (e.g. site) in the "Web context key" field
  3. Complete installation
  4. Verify config.context.php exists in web root with return 'site';
  5. Verify site loads with the custom context

Validation:

  • Empty key → fallback to web
  • Invalid chars (e.g. site-key) → error on web, fallback on CLI
  • Reserved keys (mgr, root) → error on web, fallback on CLI

Related issue(s)/PR(s)

Resolves #14462

@Ibochkarev Ibochkarev marked this pull request as ready for review February 26, 2026 04:50
- Add context_web_key option to CLI and web installer
- Validate key: alphanumeric + underscore, forbid mgr/root
- Write config.context.php for index.php context resolution
- Rename web context in DB when custom key is used

Resolves modxcms#14462
@Ibochkarev Ibochkarev force-pushed the feat/context-web-key-14462 branch from 4bdf7e9 to 5e90445 Compare February 26, 2026 04:51
@Ibochkarev Ibochkarev added the feature Request about implementing a brand new function or possibility. label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Request about implementing a brand new function or possibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MODX 3 Feature Request - Allow an alternative to context key 'web' on install.

1 participant