1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-20 20:44:03 +00:00
Automatic multi-tenancy for Laravel. No code changes needed. https://tenancyforlaravel.com
Find a file
lukinovec ec06dcc52e
Correct DomainTenantResolver::isSubdomain() check (#1425)
Added a failing test for determining if a host is a subdomain, then
fixed `DomainTenantResolver::isSubdomain()` (similar fix as in #1423)
and a related assertion.

Previously, while having `tenancy.identification.central_domains` set to
e.g. `['site.com']`, the `isSubdomain()` check consider `tenantsite.com`
a subdomain because it ends with `site.com`. Now, instead of the
`endsWith()` check, the method checks if the passed domain is in the
configured central domains. If it is, it returns `false`. Otherwise,
loop through all the central domains and check if the passed domain
matches any of the central domains prefixed with a dot (e.g.
`tenant.site.com` would be considered a subdomain, `tenant.site.com`
wouldn't).

Because in InitializeTenancyByDomainOrSubdomain, if tenancy fails to
initialize using a subdomain (before this PR's changes, e.g.
`tenantsite.com` would be considered a subdomain, and `tenantsite` would
be used for initializing tenancy), it'll catch the exception and use the
whole domain for identification instead, this error will likely never be
noticed in real-world usage. So this PR corrects the subdomain detection
logic, but the real-world impact of that is negligible.

> Note: The subdomain error catching logic in domainOrSubdomain ID MW
was added in v4. If we applied this change in v3, it'd fix a real issue
where domainOrSubdomain ID MW would just fail at the subdomain
initialization, without attempting domain initialization after the
failure.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2026-05-11 14:26:06 +02:00
.github [4.x] Laravel 13 support (#1443) 2026-03-18 19:17:28 +01:00
art Update artwork 2020-06-09 15:36:47 +02:00
assets Change tenant storage listeners into jobs (#1446) 2026-04-22 16:45:54 +02:00
doctum wip 2023-04-14 17:23:19 +02:00
extensions [4.x] Add DisallowSqliteAttach feature (#1283) 2025-01-04 15:34:37 +01:00
src Correct DomainTenantResolver::isSubdomain() check (#1425) 2026-05-11 14:26:06 +02:00
tests Correct DomainTenantResolver::isSubdomain() check (#1425) 2026-05-11 14:26:06 +02:00
typedefs parallel commands: core # autodetect, bugfixes, improved output 2024-09-27 23:02:03 +02:00
.gitattributes misc: update .gitattributes and .nvim.lua 2025-10-13 16:14:15 +02:00
.gitignore Laravel 11 support + Docker improvements (#29) 2024-02-18 00:18:31 +01:00
.nvim.lua misc: update .gitattributes and .nvim.lua 2025-10-13 16:14:15 +02:00
.php-cs-fixer.php [4.x] Cloning: addTenantParameter(bool), domain(string|null) (#1374) 2025-07-29 17:17:32 +02:00
CLAUDE.md [4.x] URL generation, request data identification improvements (#1357) 2025-06-02 03:43:47 +02:00
composer.json [4.x] Update Pest to v4 (#1430) 2026-03-30 09:44:53 +02:00
CONTRIBUTING.md TSP stub: remove unnecessary imports 2025-12-12 20:20:29 +01:00
docker-compose-m1.override.yml use mysql:8 in docker 2025-01-21 15:23:17 +01:00
docker-compose.yml docker: change mssql env yaml syntax 2026-05-01 15:55:06 +02:00
Dockerfile PHP 8.5 support 2025-10-20 01:44:24 +02:00
DONATIONS.md update md files 2020-06-08 22:42:13 +02:00
INTERNAL.md [4.x] Add DisallowSqliteAttach feature (#1283) 2025-01-04 15:34:37 +01:00
LICENSE Initial commit 2019-01-17 22:24:12 +01:00
phpstan.neon globalUrl: useAssetOrigin() instead of setAssetRoot() 2025-11-14 10:59:31 +01:00
phpunit.xml Misc test fixes (#44) 2024-04-06 19:17:34 +02:00
README.md pending tenants: minor cleanup 2025-10-29 22:54:53 +01:00
static_properties.nu util: add static_properties.nu, more portable shebangs, PHP 8.5 beta 2025-09-22 00:20:33 +02:00
SUPPORT.md Discord link 2022-06-13 19:16:35 +02:00
t util: add static_properties.nu, more portable shebangs, PHP 8.5 beta 2025-09-22 00:20:33 +02:00
test util: add static_properties.nu, more portable shebangs, PHP 8.5 beta 2025-09-22 00:20:33 +02:00

Tenancy for Laravel logo

Laravel 11.x Latest Stable Version GitHub Actions CI status Donate

Tenancy for Laravel — stancl/tenancy

Automatic multi-tenancy for your Laravel app.

You won't have to change a thing in your application's code.

  • ✔️ No model traits to change database connection
  • ✔️ No replacing of Laravel classes (Cache, Storage, ...) with tenancy-aware classes
  • ✔️ Built-in tenant identification based on hostname (including second level domains)

Documentation

Documentation can be found here: https://v4.tenancyforlaravel.com

Need help?

Credits