Download the PHP package marcot89/laravel-magic-routes without Composer

On this page you can find all versions of the php package marcot89/laravel-magic-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-magic-routes

LaravelMagicRoutes

Latest Version on Packagist Total Downloads

Create RESTfull routes for your laravel app based on your controller names and namespaces to avoid overrides and define a pattern to your projects routes. It is compatible with laravel 7+.

Installation

Via Composer

Usage

Add MagicRoutes trait to the controller to generate routes for it automatically:

For now there is no route for your controller because you don't have any public method declared on it. A new route will be generated for every public method added to the controller. So if we add the common crud public methods like this:

We will have these generated routes based on those public methods:

# Customize Http Methods for Routes

Any other public method in the controller will be generated a route with a GET http method as default, but you can customize it with a prefix. Let's see an example.

# Route Params

By convention the first parameter will be set before the action name. All other parameters will be added after.

Will generate:

# Middlewares

There are two ways to declare a middleware for a controller:

Using Protected Property

Using Constructor

# Namespaced Routes

The controller namespace will generate a prefix for that route:

Any public method declared in this controller will generate urls with prefix like:

And named routes like:

# Invokable Controllers

If you like to create a controller for every action you can use the invokable controllers in a namespaced that makes sense for your route. Example:

This will generate an URL like:

# Nested RESTfull Routes

Sometimes you want or need to define nested resources. Let's say we have posts of a user but we want nested routes for that. You can do it with a namespaced controller like this:

This will generate the following route:

# Resource URLs Plural vs Singular

RESTfull resources is always in plural. So the convention defines URL resources in plural no matter the name of the controller. If your controller is UserController or UsersController both will generate the same resource URL /users.

But you can disable this behavior using the plural property:

With this property false will generate routes following the controller name. Now if your controller is UserController it will generate a route /user. If it is UsersController it will generate /users.

Note: For invokable controllers the plural property is always disabled.

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

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

Credits

MIT License

Please see the license file for more information.


All versions of laravel-magic-routes with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~7
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 marcot89/laravel-magic-routes contains the following files

Loading the files please wait ....