Download the PHP package dentro/yalr without Composer

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

YALR (Yet Another Laravel Router)

Test Coding Standard codecov Total Downloads Laravel Octane Compatible

Define Laravel routes in different ways using Route Attribute

Previously known as jalameta/router.

Table of Contents

Installation

Using Composer:

Requirements

Laravel Yalr PHP
8.x ^1.0 ^8.0
9.x ^1.1 ^8.0
10.x ^1.2 ^8.0
11.x ^1.3 ^8.1
12.x ^1.4 ^8.2
12.x ^1.5 ^8.3

Getting Started

After installation, run the following command in your project:

Class Wrapper Route

Class wrapper route is our effort to make routing in Laravel more expressive and organized. Routes are represented by their namespace for easier understanding. For example, class App\Admin\TransactionRoute will correspond to the route /app/admin/transaction.

Creating New Route

To create a new route, run:

This command will create a route named DefaultRoute in app/Http/Routes/DefaultRoute.php. Note that after creation, you must register the Route class in your route configuration for it to be loaded.

make:route Options

1. Inject

The --inject option automatically adds the route class name to your route configuration:

This command creates the Default route and adds it to the web group defined in config/routes.php.

2. Controller

The --controller option generates both the route and its associated controller:

This eliminates the need to run two separate commands to create a controller and route.

3. Help

Shows the YALR command help information.

Routes Configuration

Here's an example of a YALR configuration file:

The groups section defines group configurations where you can specify Laravel options such as as, domain, middleware, prefix, etc. The web and api sections contain arrays of route class names that belong to these groups.

Class Structure

Here's an example of a generated route file:

Define routes within the register method by calling $this->router, which is a router instance. You can invoke Laravel routing methods such as get, post, put, etc. See Laravel Routing Documentation for more details.

Note: Avoid using closure actions, as your application will encounter errors when routes are cached.

Example with prefix and name properties:

Using Controller

When creating a route with the controller option, the controller class will be referenced in a controller method:

This route is equivalent to:

This package helps eliminate duplicate namespace and class name references in your route definitions. If you want to use a different controller than the one specified in the controller() method, you can pass the controller class as the second parameter of $this->uses():

Route Prefix

You can override the default prefix (which is '/') by defining it in your class property:

Then use it in your routes:

This is equivalent to:

Route Name

Define a route name property in your route class:

Then use the $this->name() method, which adds a dot (.) between the route group name and the individual route name:

This is equivalent to:

Preloads

Preloads always run even when routes are cached. They're an ideal place for route model binding and rate limiters:

Route Attribute

PHP 8 introduced a feature called Attributes (see PHP 8 Attributes). YALR leverages this feature to enable more elegant route definitions:

Available Class Target

Available Method Target

Detailed Attribute Examples

Basic Controller with Multiple Routes

Controller with Middleware

API Controller Example

Adding Controllers to Route Configuration

Simply add controller classes to your route configuration, and YALR will determine how to handle them:

Auto Injection

YALR provides automatic class injection through the configuration file. You can specify directories containing either your controllers with PHP 8 attributes or your route wrapper classes, and YALR will scan and inject them into your routes configuration.

Configure the injects section in config/routes.php:

You can specify multiple directories for each group:

Note: The directory scan is not recursive. YALR will only read files in the specified directories and won't search within their subdirectories.

To generate routes based on your class structure, run:

Available Commands

yalr:install

Installs YALR into your Laravel project by publishing the necessary configuration files:

Options:

When using --transform, YALR will:

  1. Scan your routes directory for traditional Laravel route files
  2. Convert Route facade calls to YALR class-based format
  3. Store the new route classes in app/Http/Routes directory
  4. Preserve middleware, prefixes, and other route configurations
  5. Create backups of original files with .bak extension if --backup is specified

yalr:display

Displays all registered routes grouped by their configuration sections:

yalr:generate

Scans controller directories specified in the injects configuration and automatically adds them to the appropriate route groups:

make:route

Creates a new route class with optional controller generation and route injection:

Options:


All versions of yalr with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/console Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/routing Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/filesystem Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0|^12.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 dentro/yalr contains the following files

Loading the files please wait ....