PHPackages                             jalameta/jps-router - 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. jalameta/jps-router

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

jalameta/jps-router
===================

v0.1.6(6y ago)314.0k2[1 issues](https://github.com/jalameta/jps-router/issues)MITPHP

Since Aug 6Pushed 5y ago4 watchersCompare

[ Source](https://github.com/jalameta/jps-router)[ Packagist](https://packagist.org/packages/jalameta/jps-router)[ RSS](/packages/jalameta-jps-router/feed)WikiDiscussions master Synced 3w ago

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

JPS Router
----------

[](#jps-router)

Laravel custom route wrapper by PT. Jalameta Pilar Sinergis.

### Installation

[](#installation)

Using composer:

> `composer require jalameta/jps-router`

### Applying into your project

[](#applying-into-your-project)

Laravel &gt;= 5.8

- Automatically loaded :)

Laravel &lt;= 5.8

- Add the `\Jalameta\Router\RouterServiceProvider` into `providers` array in `config/app.php`

Run command in your project

> `php artisan jps:routes --install`

If you deciding to remove the original laravel routes, you might add `--remove` option within the command. So the command will be

> `php artisan jps:routes --install --remove`

> JPS Router will configure the routes for you, the Laravel default `routes` folder will be **deleted**. So backup your defined routes first.

### Usage

[](#usage)

#### Creating new route

[](#creating-new-route)

To make a new route just run: `php artisan make:route DefaultRoute`After running command above, the route named `DefaultRoute` will appear in `app/Http/Routes/DefaultRoute.php`. After creating routes, it will not be loaded automatically, you must register the Route Class in the route configuration.

##### make:route options

[](#makeroute-options)

1. Inject Inject is useful options to auto adding the route class name within route configuration, so you don't need to add it manually. E.g: `php artisan make:route DefaultRoute --inject web`Command above will make the Default route within the web groups that defined in `config/routes.php`.
2. Controller The controller option will generate the route and the controller used by the route. So you don't need to run 2 artisan command to create a new controller and route. `php artisan make:route DefaultRoute --controller HomeController`
3. Help Shows JPS router command helps

#### Routes Configuration

[](#routes-configuration)

Below is an example of JPS router configurations.

```
return [
    'groups' => [
        'web' => [
            'middleware' => 'web',
            'prefix' => '',
        ],
        'api' => [
            'middleware' => 'api',
            'prefix' => 'api',
        ],
    ],

    'web' => [
        /** @inject web **/
	\App\Http\Routes\DefaultRoute::class,
    ],
    'api' => [
        /** @inject api **/
    ],
];
```

As you can see, `groups` index is group configuration, you can pass any laravel options there such as `as`, `domain`, `middleware`, `prefix`, etc. Afterward, the `web` and `api` are group index defined before in the `groups` index. It is an array of route class names.

#### Class Structure

[](#class-structure)

After creating a route with the command, we will see the example of the generated file.

```
