Skip to content

Conversation

@binaryfire
Copy link
Contributor

@binaryfire binaryfire commented Dec 21, 2025

Summary

Ports the useOrigin() method from Laravel's UrlGenerator to Hypervel, enabling the setting of a forced root URL for all generated URLs.

This is used for multi-tenancy where URLs need to be generated for tenant-specific domains.

Usage (in middleware)

  URL::useOrigin('https://tenant1.example.com');
  url('dashboard'); // https://tenant1.example.com/dashboard

  // Clear
  URL::useOrigin(null);

Implementation

Uses coroutine Context instead of instance properties for request isolation

Add methods to force the root URL for all generated URLs, useful for
multi-tenancy scenarios where URLs need to be generated for tenant
domains (e.g., in queue jobs or CLI commands).

Unlike Laravel's instance property approach, this implementation uses
coroutine Context to store the forced root, ensuring request isolation
in Swoole's coroutine environment.
Laravel deprecated forceRootUrl in favor of useOrigin. We should only
port the current API, not deprecated methods.
@albertcht albertcht added the feature New feature or request label Dec 21, 2025
@albertcht albertcht merged commit 75f9ea3 into hypervel:main Dec 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants