Create your routes using attributes in your controllers

Related tags

Routers controller
Overview

Raihel Controller

Total Downloads Latest Stable Version License

Create your routes using attributes in your controllers

Installation

  composer install raihel/controller 

Setting

Use Controller Factory to map your routes

  • diretory: An array with the directories of your controllers
  • controllers: An array with your controller classes
  • loadRoute: The class that will do the work of including the routes mapped in your controllers in your application accepts any class that implements Raihel\Controller\Core\Load\Type\LoudRoute

Slim:

require __DIR__.'/../../vendor/autoload.php';

use App\HelloController;
use Raihel\Controller\Core\ControllerFactory;
use Slim\App;

$app = new App();

use Raihel\Controller\Core\Load\Type\SlimLoadRoute;


ControllerFactory::load(
  loadRoute: new SlimLoadRoute($app),
  diretory: [__DIR__ . '/../src'],
  controllers: [HelloController::class]
);

$app->run();

Lumen:

ControllerFactory::load(
    loadRoute: new LumenLoadRoute($router),
    diretory: [__DIR__ . '/../app/Http/Controllers'],
);

Usage/Examples

Controller

Create your controller by adding the attribute Controller in your class it can receive a prefix that groups your routes

namespace App;

use Raihel\Controller\Attributes\Controller;
use Raihel\Controller\Attributes\Route\Get;
use Raihel\Controller\Attributes\Route\Put;

#[Controller('home')]
class AppController
{
    #[Get]
    public function home()
    {
        echo 'Hello World!';
    }

    #[Get('hello'), Put('hello')]
    public function get2()
    {
        echo 'Hello World 2!';
    }
}

Routes

The attribute Get before the home method creates a GET /home endponit for application

Attributes
Get
Post
Put
Delete
Patch

Authors

License

The Raihel Controller is open-sourced software licensed under the MIT license.

You might also like...
Data providers encapsulate logic for Inertia views, keep your controllers clean and simple.

Laravel Data Providers for Inertia.js Data providers encapsulate logic for Inertia views, keep your controllers clean and simple. Installation We assu

Package to easily test crudable controllers for Laravel based API

Laravel Crudable Test This package is very usefull to easily test crudable controllers. Installation You can install package via composer. Add reposit

This small POC aims to show how Symfony is able, natively without modifications, to use subdirectories for Entities, Repositories, controllers, views…

POC - Using Sub Directories in a Symfony Project This small POC aims to show how Symfony is able, natively without modifications, to use subdirectorie

Backend controllers and scaffolding for Laravel authentication.

Introduction Laravel Fortify is a frontend agnostic authentication backend for Laravel. Fortify powers the registration, authentication, and two-facto

Sistema de Rotas com Controllers e Middlewares

Sistema de Rotas com Controllers e Middlewares

Laravel magical helpers such as Controllers / Requests / Models

Laravel Magic provides Abstract Controller, Model, generic Request, Traits, Exceptions and various middlewares in order to generate very easily and quickly API resources from scratch.

Refresh artisan commands,table,migrations,models,controllers...

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Manage redirects using database rules. Rules are intended to be very similar to Laravel default routes, so syntax is pretty easy to comprehend.

Laravel DB redirector Manage HTTP redirections in Laravel using database Manage redirects using database rules. Rules are intended to be very similar

Routes and Middleware for Using OAuth2 Server within a Slim Framework API

Chadicus\Slim\OAuth2 A collection of OAuth2 Server routes, middleware and utilities for use within a Slim 3 Framework API Requirements Chadicus\Slim\O

Control frontend access to properties/methods in Livewire using PHP 8 attributes.
Control frontend access to properties/methods in Livewire using PHP 8 attributes.

This package adds PHP 8.0 attribute support to Livewire. In specific, the attributes are used for flagging component properties and methods as frontend-accessible.

🔌 Autowire and configure using PHP 8 Attributes in Laravel.

🔌 Autowire for Laravel Autowire and configure using PHP 8 Attributes in Laravel. Installation Via Composer composer require jeroen-g/autowire You wil

A PocketMine-MP plugin that allows you to comfortably register events using a new piece of PHP 8 power — attributes.

AdvancedEvents This is a PocketMine-MP plugin that allows you to comfortably register events using a new piece of PHP 8 power — attributes. Inspired b

Declarative HTTP Clients using Guzzle HTTP Library and PHP 8 Attributes

Waffler How to install? $ composer require waffler/waffler This package requires PHP 8 or above. How to test? $ composer phpunit Quick start For our e

An easy way to desensitize your routes in your Laravel application

The package provides an easy way to desensitize your routes in your Laravel application. In short, Desensitize makes your routes case-insensitive, so you can access any of your routes whether they are lowercase, uppercase, or both.

Test your routes without hassle
Test your routes without hassle

Laravel Api Tester Live demo Try it out: laravel-api-tester.asva.by Docs Those are short and easy to read. Take a look. Interface FAQ Installation Req

Use your Laravel named routes in JavaScript
Use your Laravel named routes in JavaScript

Ziggy – Use your Laravel routes in JavaScript Ziggy provides a JavaScript route() helper function that works like Laravel's, making it easy to use you

Display your Laravel routes in the console, but make it pretty. 😎
Display your Laravel routes in the console, but make it pretty. 😎

Pretty Routes for Laravel Display your Laravel routes in the console, but make it pretty. 😎 Installation You can install the package via composer: co

Easily add routes to your Laravel app by creating Markdown or Blade files

Laravel Pages This package lets you create pages using Markdown or Blade without having to worry about creating routes or controllers yourself. Essent

permission generation for all your declared routes with corresponding controller action

Permissions Generator This package add some artisan command to help generating permissions for your declared routes. Each route should have an alias (

Releases(v0.2.1)
Owner
Raihel
Raihel
Manage redirects using database rules. Rules are intended to be very similar to Laravel default routes, so syntax is pretty easy to comprehend.

Laravel DB redirector Manage HTTP redirections in Laravel using database Manage redirects using database rules. Rules are intended to be very similar

Vladimir Ković 12 Jul 18, 2022
An easy way to desensitize your routes in your Laravel application

The package provides an easy way to desensitize your routes in your Laravel application. In short, Desensitize makes your routes case-insensitive, so you can access any of your routes whether they are lowercase, uppercase, or both.

Waryor 2 Mar 29, 2022
Generate routes documentation

Laravel Route Documentation Maybe we are wondering where these routes lead or what could be their purpose? This package decides to solve this solution

Ahmet Barut 6 Nov 16, 2022
:tada: Release 2.0 is released! Very fast HTTP router for PHP 7.1+ (incl. PHP8 with attributes) based on PSR-7 and PSR-15 with support for annotations and OpenApi (Swagger)

HTTP router for PHP 7.1+ (incl. PHP 8 with attributes) based on PSR-7 and PSR-15 with support for annotations and OpenApi (Swagger) Installation compo

Sunrise // PHP 151 Jan 5, 2023
Create your routes using attributes in your controllers

Create your routes using attributes in your controllers

Raihel 3 Jan 5, 2023
Create custom WordPress routes and redirects, restrict access by roles and/or capabilities. Routes made simple

Create custom WordPress routes and redirects, restrict access by roles and/or capabilities. Routes made simple

Joan 9 Oct 10, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Create secure controllers with routing system in Laravel.

Power Gates A simple Laravel application for testing Gates and Policy. Using laravel middlewares, routes and gates to create an Authenticated website.

AmirH.Najafizadeh 4 Jul 31, 2022
A package to help you clean up your controllers in laravel

?? Laravel Terminator ?? ?? "Tell, don't ask principle" for your laravel controllers What this package is good for ? Short answer : This package helps

Iman 241 Oct 10, 2022
A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands

A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands... at once Installation You can install the p

Coderflex 16 Nov 11, 2022