Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lewisbhs's avatar

Overwrite/Replace Spark Routes

Is there a way that I can overwrite the default spark routes? For example for some specific users I want to deny access to the /settings route, or even overwrite the it with a totally different page & functions completely.

Thanks in advance.

0 likes
1 reply
Cronix's avatar

First, in config/app.php, make sure these 2 providers are in this order. It doesn't matter where in the providers array they appear, as long as SparkServiceProvider comes before RouteServiceProvider:

Laravel\Spark\Providers\SparkServiceProvider::class,
App\Providers\RouteServiceProvider::class

Then you can just override any spark-specific routes with your own routes in the /routes/api.php or routes/web.php files. Just put your custom routes at the top and use the same url that Spark is using (unless you want to have to edit all of the views and js files using those urls since they're hardcoded) but change the controller/method it's using to yours.

As always, you will have to clear cache in between changes if your routes/config is cached.

1 like

Please or to participate in this conversation.