2017 © Pedro Peláez
 

library barud

My first Composer project

image

unmbtg/barud

My first Composer project

  • Sunday, August 6, 2017
  • by UnmBtg
  • Repository
  • 0 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

BaRud

Easy way to produce a highly customisable way to create an basic CRUD Api., (*1)

Basics

This are the basics components of the Crud., (*2)

  • Entities: They're responsible to represent something that must be stored.
  • Criterias: They represent a way to search for something.
  • Repositories: They're the way to store one Entity in one permanent state. They're also tasked to be able to retrieve the given Entity
  • Services: They're where basic procidures must remain utilizing the Repositories to permament store the given procidures.
  • Presenter: They give a better look for one given information.
  • Transformer: They make one good looking (Presentable) information into something else.
  • Validators: Validations that must be placed before storing something premanentely, used on Repositories.

Usage

Step 1: Create an Entity, (*3)

In order to store something create an Entity, something around this lines., (*4)

<?php
 class Foo implements EntityInterface{}

This will make the Entity recognizeble by all the other methods. If you're using Elloquent there's already an wrapper that will implements all necessaries methods EloquentWarper\Model, (*5)

Step 2: Create the Validations It follows the Laravel Validator ways see more at -https://laravel.com/docs/5.4/validation, (*6)

Example:, (*7)

<?php

class FooValdiator extends ValidatorAbstract
{
    public function createRules()
    {
        return [
            'boo' => 'required'
        ];  
    }

    public function createMessages()
    {
        return [];
    }
}

Step 3:, (*8)

Create some endpoits and implement the Controlify Trait, (*9)

Example:, (*10)

<?php

namespace App\Http\Controllers\Api\V1;


use UnmBtg\Controllers\ControllerInterface;
use UnmBtg\Controllers\Controllify;
use UnmBtg\Entities\EntityInterface;
use UnmBtg\Services\DefaultService;

class FooController extends Controller implements ControllerInterface
{
    use Controllify;

    protected $validatorException = ValidateException::class;

    protected $serviceClass = DefaultService::class;

    /**
     * @var EntityInterface
     */
    protected $entity;

    public function __construct()
    {
        \App::setLocale("pt_br");
        $this->service = new $this->serviceClass(new $this->entity);
    }

    public function index(Request $request) {
        return $this->indexRequest($request->all());
    }

    public function store(Request $request)
    {
        return $this->storeRequest($request->all());
    }

    public function update($id, Request $request)
    {
        return $this->updateRequest($id, $request->all());
    }

    public function destroy($id) {
        return $this->deleteRequest($id);
    }

    public function show($id) {
        return $this->showRequest($id);
    }
}

The Versions

06/08 2017

dev-master

9999999-dev

My first Composer project

  Sources   Download

The Requires

 

by Marco Augusto

02/08 2017

dev-concept

dev-concept

My first Composer project

  Sources   Download

The Requires

 

by Marco Augusto