Download the PHP package shiftonelabs/laravel-singular-resource-routes without Composer

On this page you can find all versions of the php package shiftonelabs/laravel-singular-resource-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-singular-resource-routes

laravel-singular-resource-routes

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

This Laravel package adds support for singular resource routes to Laravel's router.

Sometimes you need to deal with a resource that does not need to be referenced by the id. For example, you may have a profile resource that belongs to the currently authenticated user. Currently, if you wanted to show the user's profile, the route would be /profile/{profile}. However, since you don't need the id to look up the current user's profile, it would be nice to be able to simply have the show route be /profile. This is the same for the edit, update, and destroy routes, as well.

The singular resource route generates the following routes:

Verb Path Action Route Name
GET /profile/create create profile.create
POST /profile store profile.store
GET /profile show profile.show
GET /profile/edit edit profile.edit
PUT/PATCH /profile update profile.update
DELETE /profile destroy profile.destroy

These routes differ from the current resource routes in two ways:

  1. The show, edit, update, and destroy routes do not need a route parameter.
  2. Since this is a singular resource, there is no index action.

Versions

This package has been tested on Laravel 5.0 through Laravel 8.x, though it may continue to work on later versions as they are released. This section will be updated to reflect the versions on which the package has actually been tested.

Install

Via Composer

Service Provider

This package supports Laravel package autodiscovery. So, if using Laravel 5.5+, there is no need to add the server provider. If using Laravel 5.0 - 5.4, add the service provider to your config/app.php file:

Usage

In order to create a new singular resource route, a new singular option is added to the resource route definition. This option can be set to three different values:

  1. The boolean true. This is mainly for non-nested resource definitions. If it is used on a nested resource definition, only the last resource in the chain will be treated as singular.
  2. A string containing the name of the singular resource. This can be used when there is only one resource that is singular in a nested resource definition. The string must contain the name of the singular resource.
  3. An array of strings containing the names of the singular resources. This format must be used when there are multiple singular resources in a nested resource definition, but it can be used in any scenario.

Code Example

A singular resource (/profile):

A singular resource nested under a plural resource (/users/{user}/profile):

A singular resource nested under a singular resource (/profile/avatar):

A plural resource nested under a singular resource (/profile/phones/{phone}):

A singular resource nested under a plural resource nested under a singular resource (/profile/phones/{phone}/type):

Contributing

Contributions are welcome. Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-singular-resource-routes with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
illuminate/routing Version >=5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shiftonelabs/laravel-singular-resource-routes contains the following files

Loading the files please wait ....