Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Base Path Laravel Package

middlewares/base-path

A small Laravel middleware package for apps served from a subdirectory. It helps normalize the base path so routes, redirects, and generated URLs work correctly behind a path prefix, with simple middleware registration and minimal setup.

View on GitHub
Deep Wiki
Context7

Middleware to remove the prefix from the uri path of the request.

Frequently asked questions about Base Path
What does the middlewares/base-path package do in Laravel?
It is a lightweight Laravel middleware that sets the application's base path at runtime. That lets an app be served from a subdirectory or another dynamic location without changing bootstrap/app.php or the server configuration. It is framework-native and has no external dependencies.
How do I install middlewares/base-path?
Install it through Composer using the package name middlewares/base-path. The package overview does not mention a service provider or configuration file, so installation is typically just the Composer require step plus middleware registration. Check Packagist for the exact latest version and PHP requirements.
How do I register the base path middleware in Laravel?
Register the package's middleware the same way you register any Laravel middleware, either globally or on the routes that need the base path override. The overview says registration is simple and requires no configuration. Because the exact class name is not included in the provided context, confirm it from the package README or source before adding it to your middleware stack.
Can middlewares/base-path serve a Laravel app from a subdirectory?
Yes. The package is specifically described as useful for apps served from a subdirectory. It normalizes the base path at runtime so routes, redirects, and generated URLs can work correctly behind a path prefix. You still need your web server and front controller to route requests to Laravel as usual.
Does this package support multi-tenant Laravel deployments?
The overview lists subdirectory and multi-tenant deployments as ideal use cases. Because the base path is set per request, different tenants or request contexts can resolve to different locations at runtime. The package itself is minimal, so tenant detection and path selection logic remain your responsibility.
Do I need to edit bootstrap/app.php or my web server config?
The package is designed so you do not have to touch bootstrap/app.php just to change the base path. Its stated benefit is avoiding that edit for subdirectory or dynamic deployments. Server configuration may still matter for routing requests into the application, but the base path override happens in middleware.
Will middlewares/base-path fix route, redirect, and asset URL generation?
The package blurb says it helps routes, redirects, and generated URLs work correctly behind a path prefix by normalizing the base path. That is the intended effect for URL generation that relies on Laravel's base path. You should still test asset URLs and any hard-coded paths, because those can depend on separate configuration such as ASSET_URL.
Which Laravel versions are supported by middlewares/base-path?
The provided package overview does not list specific Laravel or PHP version constraints. Check the package's composer.json on Packagist for its illuminate/support and PHP requirements before installing. That is the reliable way to confirm compatibility with your Laravel version.
How should I test that the base path is set correctly?
Add a request or feature test that sends a request through the middleware and asserts the resolved application base path or a generated route URL. Check that redirects and URLs include the expected prefix. Also test a request outside the subdirectory to confirm the middleware does not leak state between requests.
Is middlewares/base-path actively maintained and production-ready?
The repository is unknown in the provided context, so check Packagist release history and the linked source repository for recent commits and Laravel compatibility. The package is described as lightweight with no external dependencies, which keeps its production footprint small. As with any small middleware package, review the source and pin a version in composer.lock.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager