Giter Club home page Giter Club logo

slime-framework's Introduction

slime-framework's People

Contributors

vikkio88 avatar

Watchers

 avatar  avatar  avatar

slime-framework's Issues

Fix tests

Some tests broke after fixing the issue related to exception codes on http code

Create Endpoint command

php novice create_endpoint [endpoint name] [params]
the create Enpoint command will:

  • generate the routes
  • generate the actions
  • generate the model
  • generate the Acceptance tests

It will be nice make it able to choose if is just the route that we want or the whole CRUD ops, that is why params come in handy:
PoC

  • php novice create_endpoint users crud will create CRUD operations endpoint, model and actions
  • php novice create_enpoind users\settings --no-model will just add a new enpoint on the users routes and will nor create the model

Generator with Namespace

  • All the generators of phpclasses should include namespace
  • Generated file should be generated in the right subdir named after the namespace

Create Filter Trait for Models

as done for the Pagination Trait, I will need to add a way to intercept and generate where clauses based on query params, probably worth take a look at how much is worth it using Laravel/Scout instead of simple eloquent as done before

  • Implement method to get query params within the Action
  • Implement extendable filter scope on Model

usage example

<?php


namespace App\Actions\User;

use App\Lib\Slime\RestAction\ApiAction;
use App\Lib\Slime\RestAction\Traits\Pagination;
use App\Models\Users\User;

class UserGetAll extends ApiAction
{
    use Pagination;

    protected function performAction()
    {
        $this->pagination = $this->getPaginationParams($this->request);
        $this->payload = User::filter(
            $this->getQueryParams()
        )->page(
            $this->pagination
        )->get();
    }
}

Where within the model

<?php

namespace App\Models\Users;

use App\Lib\Slime\Models\SlimeModel;

class User extends SlimeModel
{
    /**
     * @var array
     */
    protected $fillable = [
        'name',
        'surname',
        'email',
        'age',
    ];

    protected $filters = [
        'name' => [
            'col' => 'name',
            'op' => 'LIKE'
        ]
    ];
}

in that way we will get, calling
GET /users?name=%ali%
response

{
  "code": 200,
  "message": "OK",
  "payload": [
    {
      "id": 1,
      "name": "Sherman Balistreri",
      "username": "israel40",
      "email": "[email protected]"
    },
    {
      "id": 2,
      "name": "Mrs. Coralie Grady",
      "username": "rempel.meta",
      "email": "[email protected]"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20
  }
}

pagination scope (using fluent interface) can be easily concatenated

Create build command

php novice build
Build command will:

  • generate an ftp uploadable build of the api in a dist/ folder
    Build command will possibly:
  • remove unused dependecy from composer and generate a light vendor folder

Create Export Migration command

create a command to export migration to plain sql

  • If you execute php novice export_migration you will get a sql file
  • need to add wheter to export just table structure or even data dumps

Build & deploy command

Build command should install only if composer hast changed.

Deploy command via ftp should upload only the changes on the server

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.