Code Monkey home page Code Monkey logo

controller's Introduction

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.

controller's People

Contributors

heliodantas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.