Skip to content

Allow configuring the root folder for file driver redirects - #47

Open
andreasbergqvist wants to merge 4 commits into
alt-design:mainfrom
andreasbergqvist:andreasbergqvist-configurable-root-folder
Open

andreasbergqvist wants to merge 4 commits into
alt-design:mainfrom
andreasbergqvist:andreasbergqvist-configurable-root-folder

Conversation

@andreasbergqvist

Copy link
Copy Markdown
Contributor

This pull request adds support for customizing the root directory where redirect and query string YAML files are stored when using the "file" driver. All file operations within the FileRepository and related classes now use the configurable root_path instead of a hardcoded path, improving flexibility and maintainability. Tests have also been updated and extended to verify this new behavior.

Configuration changes:

  • Added a new root_path option to config/alt-redirect.php, allowing users to specify the base directory for redirect and query string files.

Repository refactoring:

  • Refactored FileRepository to use the new root_path configuration for all file operations, replacing hardcoded paths throughout methods such as find, save, delete, and getRegex. [1] [2] [3] [4] [5]

Service provider updates:

  • Updated ServiceProvider to use the configurable root_path when installing default query strings and marker files.

Test improvements:

  • Updated existing tests to respect the new root_path configuration and added a new test to verify that custom root paths are supported and function correctly. [1] [2] [3]

@Alt-Charlie Alt-Charlie self-assigned this Oct 8, 2026
@Alt-Charlie
Alt-Charlie self-requested a review October 8, 2026 16:12

@Alt-Charlie Alt-Charlie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @andreasbergqvist thanks for this, it's a useful option and sorry for the wait. I've tested it with relative and absolute paths, and redirects, regex redirects, query strings and the install marker all end up in the configured folder as expected. A few things before we merge:

1. The new test fails

it can set custom root path in configuration returns a 404 instead of a 301. The test saves through a new FileRepository, but the middleware gets its repository from the RepositoryManager singleton. That manager already created the file driver during boot with the default path, so the request looks in content/alt-redirect. Calling app(RepositoryManager::class)->forgetDrivers() after changing the config, then saving through app(RepositoryInterface::class), makes it pass and tests the same path the middleware uses.

2. Documentation

Could you add the new option to the README? The storage section still says files live in content/alt-redirect/.

Hope that makes sense. Any questions or alternative thoughts please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants