PHPackages                             amdadulhaq/route-resource-paths-laravel - 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. [API Development](/categories/api)
4. /
5. amdadulhaq/route-resource-paths-laravel

ActiveLibrary[API Development](/categories/api)

amdadulhaq/route-resource-paths-laravel
=======================================

A Laravel package that provides a resource paths registrar.

v1.0.0(4mo ago)0266MITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Oct 17Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/amdad121/route-resource-paths-laravel)[ Packagist](https://packagist.org/packages/amdadulhaq/route-resource-paths-laravel)[ GitHub Sponsors](https://github.com/amdad121)[ RSS](/packages/amdadulhaq-route-resource-paths-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (8)Used By (0)

Route Resource Paths Laravel Package
====================================

[](#route-resource-paths-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbab805f4460ea4ee2ffd50adeffdf3314d575e500428670b8fbcac5552b88af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d646164756c6861712f726f7574652d7265736f757263652d70617468732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/route-resource-paths-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ed642e8b20548fc605bb0507aa9bed693da68fb3f7f8d35f7d56b2ccd30f2d4f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d646164756c6861712f726f7574652d7265736f757263652d70617468732d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/amdad121/route-resource-paths-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/c746f2f1ae0a83b8fcfef16bcac052b5d238dcd231dd1ea9b8d5514250328ffe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d6461643132312f726f7574652d7265736f757263652d70617468732d6c61726176656c2f6c696e742e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/amdad121/route-resource-paths-laravel/actions?query=workflow%3A%22Fix+Code+Style%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/28bb444eaf85aa0d0eeff3e8b773ca77d7695f448c03d5cee9140e4cf2211ae5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d646164756c6861712f726f7574652d7265736f757263652d70617468732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/route-resource-paths-laravel)

This Laravel package allows you to define custom paths for create and edit routes in resource controllers. It extends the functionality of Laravel's resource routing by providing macros to set these paths globally or for specific resources.

Features
--------

[](#features)

- Set global custom paths for create and edit actions across all resource routes
- Customize paths individually for each resource route
- Support for both regular resource routes and singleton resource routes
- Works seamlessly with both `Route::resource()` and `Route::resources()` methods
- Override global settings with per-resource customization
- Zero configuration required - works out of the box

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

[](#installation)

You can install the package via composer:

```
composer require amdadulhaq/route-resource-paths-laravel
```

Once installed, the service provider will be registered automatically by Laravel.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, 12.x, or 13.x

Configuration
-------------

[](#configuration)

No additional configuration is required. The package uses Laravel's built-in service container to bind and replace the default resource registrar.

Usage
-----

[](#usage)

### Setting Global Paths

[](#setting-global-paths)

To set custom paths for the create and edit actions that will apply globally to all resource routes, use the `Route::resourcePaths()` method:

```
Route::resourcePaths([
    'create' => 'add',
    'edit' => 'change',
]);
```

After setting these global paths, all resource routes defined using `Route::resource()` will use these custom paths instead of the default ones.

### Using Global Paths with Route::resource()

[](#using-global-paths-with-routeresource)

The global paths will automatically be applied to all resource controllers like this:

```
Route::resource('posts', PostController::class);
```

This will generate routes such as:

- `GET /posts/add` instead of `GET /posts/create`
- `GET /posts/{post}/change` instead of `GET /posts/{post}/edit`

### Using Global Paths with Route::resources()

[](#using-global-paths-with-routeresources)

You can also use the global paths when registering multiple resource controllers at once:

```
Route::resources([
    'photos' => PhotoController::class,
    'posts' => PostController::class,
]);
```

This will apply the same custom paths to both photos and posts resource routes.

### Setting Custom Paths for Specific Resources

[](#setting-custom-paths-for-specific-resources)

If you want to set custom paths for a specific resource, you can do so directly when defining the resource using the `paths()` method:

```
Route::resource('users', UserController::class)->paths([
    'create' => 'add',
    'edit' => 'change',
]);
```

This will only affect the routes for the users resource:

- `GET /users/add` instead of `GET /users/create`
- `GET /users/{user}/change` instead of `GET /users/{user}/edit`

### Combining Global and Specific Paths

[](#combining-global-and-specific-paths)

You can set global paths and override them for specific resources:

```
// Set global paths
Route::resourcePaths([
    'create' => 'add',
    'edit' => 'change',
]);

// Use global paths for most resources
Route::resource('posts', PostController::class);

// Override for specific resource
Route::resource('users', UserController::class)->paths([
    'create' => 'register',
    'edit' => 'update',
]);
```

In this example:

- Posts will use `/posts/add` and `/posts/{post}/change`
- Users will use `/users/register` and `/users/{user}/update`

### Setting Paths for Multiple Resources

[](#setting-paths-for-multiple-resources)

When registering multiple resources with `Route::resources()`, you can apply custom paths to all of them:

```
Route::resources([
    'photos' => PhotoController::class,
    'posts' => PostController::class,
])->paths([
    'create' => 'add',
    'edit' => 'modify',
]);
```

### Singleton Resource Paths

[](#singleton-resource-paths)

The package also supports singleton resources. Use the `Route::singletonPaths()` method to set global singleton paths:

```
Route::singletonPaths([
    'create' => 'setup',
    'edit' => 'modify',
]);
```

Then define your singleton resource:

```
Route::singleton('profile', ProfileController::class)->creatable();
```

This will generate the following routes:

- `GET /profile/setup` instead of `GET /profile/create`
- `GET /profile/modify` instead of `GET /profile/edit`

### Custom Paths for Specific Singleton Resources

[](#custom-paths-for-specific-singleton-resources)

You can also set custom paths per singleton resource:

```
Route::singleton('profile', ProfileController::class)
    ->creatable()
    ->paths([
        'create' => 'setup',
        'edit' => 'modify',
    ]);
```

API Reference
-------------

[](#api-reference)

### Route Macros

[](#route-macros)

#### `Route::resourcePaths(array $paths)`

[](#routeresourcepathsarray-paths)

Sets global custom paths for all resource routes.

**Parameters:**

- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.

**Example:**

```
Route::resourcePaths([
    'create' => 'add',
    'edit' => 'change',
]);
```

#### `Route::singletonPaths(array $paths)`

[](#routesingletonpathsarray-paths)

Sets global custom paths for all singleton resource routes.

**Parameters:**

- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.

**Example:**

```
Route::singletonPaths([
    'create' => 'setup',
    'edit' => 'modify',
]);
```

#### `Route::resources(array $resources)`

[](#routeresourcesarray-resources)

Registers multiple resource controllers at once and returns a chainable object that can apply custom paths.

**Parameters:**

- `$resources` (array): An associative array where keys are resource names and values are controller class names.

**Returns:** An object with a `paths()` method to apply custom paths.

**Example:**

```
Route::resources([
    'photos' => PhotoController::class,
    'posts' => PostController::class,
])->paths([
    'create' => 'add',
    'edit' => 'change',
]);
```

### Resource Registration Methods

[](#resource-registration-methods)

#### `PendingResourceRegistration::paths(array $paths)`

[](#pendingresourceregistrationpathsarray-paths)

Sets custom paths for a specific resource registration.

**Parameters:**

- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.

**Returns:** `PendingResourceRegistration` instance for method chaining.

**Example:**

```
Route::resource('users', UserController::class)->paths([
    'create' => 'register',
    'edit' => 'update',
]);
```

#### `PendingSingletonResourceRegistration::paths(array $paths)`

[](#pendingsingletonresourceregistrationpathsarray-paths)

Sets custom paths for a specific singleton resource registration.

**Parameters:**

- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.

**Returns:** `PendingSingletonResourceRegistration` instance for method chaining.

**Example:**

```
Route::singleton('profile', ProfileController::class)
    ->creatable()
    ->paths([
        'create' => 'setup',
        'edit' => 'modify',
    ]);
```

Complete Example
----------------

[](#complete-example)

Here's a complete example showing various ways to use the package:

```
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PostController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ProfileController;

// routes/web.php

// Set global paths for all resources
Route::resourcePaths([
    'create' => 'add',
    'edit' => 'change',
]);

// Set global paths for all singleton resources
Route::singletonPaths([
    'create' => 'setup',
    'edit' => 'modify',
]);

// Posts will use global paths: /posts/add, /posts/{post}/change
Route::resource('posts', PostController::class);

// Users will override global paths: /users/register, /users/{user}/update
Route::resource('users', UserController::class)->paths([
    'create' => 'register',
    'edit' => 'update',
]);

// Multiple resources with shared custom paths
Route::resources([
    'photos' => PhotoController::class,
    'albums' => AlbumController::class,
])->paths([
    'create' => 'upload',
    'edit' => 'edit',
]);

// Singleton with custom paths
Route::singleton('profile', ProfileController::class)
    ->creatable()
    ->paths([
        'create' => 'setup',
        'edit' => 'modify',
    ]);
```

Troubleshooting
---------------

[](#troubleshooting)

### Paths not working

[](#paths-not-working)

If the custom paths are not working:

1. Ensure the service provider is registered (it should be auto-discovered in Laravel)
2. Check that you're calling the macro methods before defining your resources
3. Verify the package is installed correctly by checking `composer show amdadulhaq/route-resource-paths-laravel`

### Conflicts with other packages

[](#conflicts-with-other-packages)

If you're using other packages that also modify the resource registrar, ensure there are no conflicts by:

1. Checking the order of service provider registration
2. Testing with a fresh Laravel installation
3. Reviewing other packages' documentation

Migration Guide
---------------

[](#migration-guide)

If you're upgrading from an older version:

1. No breaking changes - the API remains the same
2. Check the changelog for new features and improvements
3. Ensure your Laravel version meets the requirements (10.x, 11.x, 12.x, or 13.x)

Credits
-------

[](#credits)

- [Amdadul Haq](https://github.com/amdad121)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Contributing
------------

[](#contributing)

If you find any issues or have suggestions for improvements, feel free to create a pull request or open an issue on the [GitHub repository](https://github.com/amdad121/route-resource-paths-laravel).

Support
-------

[](#support)

For support, email  or open an issue on GitHub.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance83

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~73 days

Recently: every ~110 days

Total

7

Last Release

130d ago

Major Versions

v0.3.1 → v1.0.02026-01-02

PHP version history (2 changes)0.1.0PHP ^8.2

v1.0.0PHP ^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/7219b32db58e53dddb8a970aec40c9a41ec7d6dbf3570fd89ac14abe7424532e?d=identicon)[amdadulhaq](/maintainers/amdadulhaq)

---

Top Contributors

[![amdad121](https://avatars.githubusercontent.com/u/11732880?v=4)](https://github.com/amdad121 "amdad121 (24 commits)")

---

Tags

laravelrouteroutes

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/amdadulhaq-route-resource-paths-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/amdadulhaq-route-resource-paths-laravel/health.svg)](https://phpackages.com/packages/amdadulhaq-route-resource-paths-laravel)
```

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k10.7M93](/packages/nuwave-lighthouse)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[api-ecosystem-for-laravel/dingo-api

A RESTful API package for the Laravel and Lumen frameworks.

3121.5M10](/packages/api-ecosystem-for-laravel-dingo-api)[reindert-vetter/api-version-control

A Laravel package to manage versions of endpoints in an elegant way

1671.0M](/packages/reindert-vetter-api-version-control)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)[mtownsend/response-xml

The missing XML support for Laravel's Response class.

1041.2M3](/packages/mtownsend-response-xml)

PHPackages © 2026

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