PHPackages                             drsoft/route-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. drsoft/route-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

drsoft/route-helper
===================

A Laravel package for managing route parameter defaults.

v1.2.2(1y ago)06MITPHPPHP &gt;=8.0

Since Dec 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/drsoft28/route-helper)[ Packagist](https://packagist.org/packages/drsoft/route-helper)[ RSS](/packages/drsoft-route-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Route Helper Package
====================

[](#route-helper-package)

This package simplifies the use of default parameters for Laravel routes. It allows you to define default values for route parameters, automatically fill them when generating URLs, and provides helper functions for route generation and redirection.

Features
--------

[](#features)

- Set and retrieve default route parameter values.
- Automatically include default parameters when generating URLs or redirecting to routes.
- Provides helper functions for route handling.

Installation
------------

[](#installation)

1. Install the package using Composer:

    ```
    composer require drsoft/route-helper
    ```
2. Add the service provider to your `config/app.php` file (if not automatically registered):

    ```
    'providers' => [
        Drsoft28\RouteHelper\RouteHelperServiceProvider::class,
    ],
    ```
3. Publish the configuration (optional):

    ```
    php artisan vendor:publish --provider="Drsoft28\\RouteHelper\\RouteHelperServiceProvider"
    ```

Usage
-----

[](#usage)

### Setting Default Route Parameters

[](#setting-default-route-parameters)

Use the `route_defaults` helper to set default values for route parameters:

```
route_defaults()->set('slug', 'default-slug');
```

### Generating Routes with Default Parameters

[](#generating-routes-with-default-parameters)

Use the `routeWithDefault` function to generate a route URL:

```
$url = routeWithDefault('vendor.home');
```

If the parameter `slug` is not provided, it will use the default value set earlier.

### Redirecting to Routes with Default Parameters

[](#redirecting-to-routes-with-default-parameters)

Use the `to_routeWithDefault` function for redirection:

```
return to_routeWithDefault('vendor.home');
```

### Accessing Default Parameter Values

[](#accessing-default-parameter-values)

Retrieve a parameter's default value:

```
$slug = route_defaults()->get('slug');
```

### Removing Default Parameter Values

[](#removing-default-parameter-values)

Remove a default parameter value:

```
route_defaults()->remove('slug');
```

### Example Scenario

[](#example-scenario)

1. Set a default value for `slug`:

    ```
    route_defaults()->set('slug', 'my-default-slug');
    ```
2. Generate a URL without passing the `slug` parameter:

    ```
    $url = routeWithDefault('vendor.home');
    echo $url; // Outputs: /my-default-slug/dashboard
    ```
3. Redirect to a route:

    ```
    return to_routeWithDefault('vendor.home');
    ```

Helpers Included
----------------

[](#helpers-included)

- **`route_defaults`**: Access the `RouteParameterDefaults` instance.
- **`routeWithDefault`**: Generate a route URL with default parameters.
- **`to_routeWithDefault`**: Redirect to a route with default parameters.

How It Works
------------

[](#how-it-works)

The package binds a singleton instance of `RouteParameterDefaults` to the service container. This instance manages the default values for route parameters and integrates them seamlessly into Laravel's route generation and redirection mechanisms.

watch in youtube
----------------

[](#watch-in-youtube)

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance40

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

509d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3b320ca3b9d89ad96eeb5595814dbf547e3316f7779113c959a311f69fd3694?d=identicon)[drsoft](/maintainers/drsoft)

---

Top Contributors

[![drsoft28](https://avatars.githubusercontent.com/u/11458383?v=4)](https://github.com/drsoft28 "drsoft28 (8 commits)")

### Embed Badge

![Health badge](/badges/drsoft-route-helper/health.svg)

```
[![Health](https://phpackages.com/badges/drsoft-route-helper/health.svg)](https://phpackages.com/packages/drsoft-route-helper)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
