Download the PHP package annotation/routing without Composer

On this page you can find all versions of the php package annotation/routing. 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 routing

Laravel Annotation Routing

Use PHP 8 attributes to register routes in a Laravel Application.

GitHub Tag Total Downloads Packagist Version Packagist PHP Version Support Packagist License

Table of Contents
  1. Quick Start
  2. Installation
  3. Usage
    1. Basic Usage
    2. Advanced Usage
    3. Specifying Prefix
    4. Specify Named
    5. Specifying Middleware
    6. Specifying Domain
    7. Specify Config
    8. Specifying ScopeBindings
    9. Specifying Where
    10. Specifying Group
    11. Specifying Defaults
    12. Specifying WithTrashed
    13. Specifying Fallback
  4. Contributing
  5. Contributors
  6. License

Quick Start

This package provides attributes to automatically register routes. Here's a quick example:

This attribute will automatically register this route:

Installation

You can install the package via Composer:

You can publish the config file with:

This is the contents of the published config file:

[back to top]

Usage

The package provides several annotations that should be put on controller classes and methods. These annotations will be used to automatically register routes.

Basic Usage

This attribute will automatically register this route:

Advanced Usage

BaseController has two subclasses: HomeController and AccountController.

HomeController:

This attribute will automatically register this route:

Route URI: http://backend.local.dev/home/index

Route Named: backend.home.index

AccountController:

This attribute will automatically register this route:

Route URI: http://passport.local.dev/account/login

Route Named: backend.passport.login

Specifying Prefix

You can use the Prefix annotation on a class to prefix the routes of all methods of that class.

These annotations will automatically register these routes:

Specify Named

All HTTP verb attributes accept a parameter named name that accepts a route name.

This attribute will automatically register this route:

Using other HTTP verbs

We have left no HTTP verb behind. You can use these attributes on controller methods.

Using multiple verbs

To register a route for all verbs, you can use the Any attribute:

To register a route for a few verbs at once, you can use the Route attribute directly:

Specifying Middleware

All HTTP verb attributes accept a parameter named middleware that accepts a middleware class or an array of middleware classes.

This annotation will automatically register this route:

To apply middleware on all methods of a class you can use the Middleware attribute. You can mix this with applying attribute on a method.

These annotations will automatically register these routes:

Specifying Domain

You can use the Domain annotation on a class to prefix the routes of all methods of that class.

These annotations will automatically register these routes:

Specify Config

There maybe a need to define a domain from a configuration file, for example where your subdomain will be different on your development environment to your production environment.

When this is parsed, it will get the value of app.url from the config file and register the route as follows:

If app.url does not exist and register the route as follows:

Specifying ScopeBindings

When implicitly binding multiple Eloquent models in a single route definition, you may wish to scope the second Eloquent model such that it must be a child of the previous Eloquent model.

By adding the ScopeBindings annotation, you can enable this behaviour:

This is akin to using the ->scopeBindings() method on the route registrar manually:

By default, Laravel will enabled scoped bindings on a route when using a custom keyed implicit binding as a nested route parameter, such as /users/{user}/posts/{post:slug}.

To disable this behaviour, you can pass false to the attribute:

This is the equivalent of calling ->withoutScopedBindings() on the route registrar manually.

You can also use the annotation on controllers to enable implicitly scoped bindings for all its methods. For any methods where you want to override this, you can pass false to the attribute on those methods, just like you would normally.

Specifying Where

You can use the Where annotation on a class or method to constrain the format of your route parameters.

These annotations will automatically register these routes:

For convenience, some commonly used regular expression patterns have helper attributes that allow you to quickly add pattern constraints to your routes.

Specifying Group

You can use the Group annotation on a class to create multiple groups with different domains and prefixes for the routes of all methods of that class.

These annotations will automatically register these routes:

Specifying Defaults

You can use the Defaults annotation on a class or method to define the default values of your optional route parameters.

These annotations will automatically register these routes:

Specifying WithTrashed

These annotations will automatically register these routes:

Specifying Fallback

These annotations will automatically register these routes:

Resource Controllers

To register a resource controller, use the Resource attribute as shown in the example below.

The attribute in the example above will automatically register following routes:

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

[back to top]

Contributors

Thanks goes to these wonderful people:

contrib.rocks image

Contributions of any kind are welcome!

[back to top]

License

Distributed under the MIT License (MIT). Please see License File for more information.

[back to top]


All versions of routing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
annotation/route Version ^2.0
reflective/reflection Version ^3.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 annotation/routing contains the following files

Loading the files please wait ...