Download the PHP package micaeldias/laravel-single-file-routes without Composer

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

Single file routes for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Single file routes allows you to co-locate everything about a route into a single file. See the route method, URI, middleware, and it's behaviour at a glance without the need to keep track of multiple files.

You can still register routes like you're used to in conjunction with this package, this is not an all-in package.

Compatibility

Laravel version PHP version Package version
8 7.4 - 8.1 1
9 - 10 8.0 - 8.2 2
9 - 10 8.0 - 8.2 3

Installation

You may install single file routes into your project with:

After installing, publish the assets using the single-file-routes:install Artisan command:

After publishing single file routes' assets, its primary configuration file will be located at config/single-file-routes.php.

Usage

Single Action Controllers

To register a route in a single action controller, simply add the Route attribute to the class itself:

Basic Controllers

To register a route in a basic controller, you need to the Route attribute to the method instead:

Route Groups

To use a route group, you first need to create one. This is easily done using the artisan command make:route-group explained below.

The route group extends the following interface:

Once you've created your desired route group, you can start adding routes under it. Let's say we create an ApiRouteGroup, to use it on a route we can simply pass the group param on the Route attribute, as such:

Route names

By default, routes' names are the same as their definition meaning you can simply pass the class name in Laravel's route method to get the URL.

Single Action Controllers

Basic Controllers

Custom Route Names

If you don't like having the route name the same as it's definition you can pass the name param on the Route attribute:

Adding middleware

You can use any middleware supported by Laravel directly in the route or on route groups to be used by all routes under it.

Route Group Middleware

To add middleware to the route group, return it from the middleware() function:

Specific Route Middleware

If you need to add middleware to a single Route, you can pass the middleware param on the Route attribute:

Multiple Routes

If for some reason you need a controller to respond to multiple URIs, you can stack as many Routes as needed:

This will make /user and /users have the same behaviour.

Route Caching

Laravel's route caching is fully supported.

In fact, due to how routes are discovered, it's highly recommended that you do cache your routes in production.

Artisan Commands

Generate Route Groups

You can easily create a route group using the make:route-group Artisan command:

Let's say we want to create an API route group:

Here's how the generated class would look like:

Generate Routes

We only support generating single action controllers using the make:route command.

Follow the prompts to generate the desired route:

Here's how the generated class would look like:

Keep in mind that the route generators were created for your convenience, but you're of course free to manually create routes or groups if it's simpler for your use-case.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-single-file-routes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
haydenpierce/class-finder Version ^0.5.3
illuminate/contracts Version ^9.0|^10.0
spatie/laravel-package-tools Version ^1.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 micaeldias/laravel-single-file-routes contains the following files

Loading the files please wait ....