selective/basepath
Selective Basepath lets Laravel routes use a different base path per request, so apps deployed in a subdirectory can still serve selected routes from the domain root. Middleware-driven configuration keeps URL generation, redirects, and assets correct without duplicating routes or rewriting config.
/app), or a path-prefixed reverse proxy without code changes or per-environment config. This package makes "base path" a runtime-detected value instead of a hardcoded constant, which directly enables "build once, deploy anywhere."/login instead of /app/login"). The decision is whether to spend engineering time on a bespoke detector or take a ~small MIT dependency. At this scope, buying (or vendoring) is almost always the right call./staging/<service>, and multi-tenant-style path partitioning where each tenant is served from a distinct prefix.Adopt when all of these hold:
setBasePath hook). This is the package's core assumption; fighting it elsewhere is wasted effort.SCRIPT_NAME, PHP_SELF, X-Forwarded-Prefix-style), not through a proprietary mechanism.urlFor()/redirect output and are willing to add your own tests around the detection logic.Look elsewhere when:
Request::root(), UrlGenerator, Request::getBasePath()), and adding this would create two competing sources of truth.symfony/http-foundation-style trust configuration. This package detects a path, it does not establish trust.To executives: This is a small, free (MIT), single-purpose utility that removes a class of deployment bugs — broken links and misdirected redirects when our app is served from a subdirectory or behind a load balancer. It costs nothing, touches one concern, and lets the same build run in more environments, which reduces release friction and environment-specific config drift. It is easily replaced: if the upstream project stalls, we vendor the source and own it at negligible cost.
To engineering: It detects the application base path from server variables and proxy headers and hands it to Slim's base path setting, so urlFor() and redirects generate correct absolute paths. Scope it as: add the dependency (pinned), wire the detector in the app bootstrap, and write our own integration tests for the three cases we actually run — root, subpath, proxy-prefixed. Do not treat it as proxy-trust configuration; pair it with an explicit trusted-proxy policy. Note the maintenance profile (small maintainer base, no downstream dependents) and prefer vendoring if our supply-chain policy requires it. Estimated effort: under a day, mostly tests.
How can I help you explore Laravel packages today?