vikkio88/slime-api

a simple RestFul API framework based on Slim v3

Installs: 39

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 3

Forks: 2

Open Issues: 0

Type:project

v0.2 2017-01-31 21:55 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:35:30 UTC


README

Build Status Scrutinizer Code Quality Code Climate Test Coverage Issue Count

Laravel is as heavy as a pregnant morbidly obese hippo and full of things that you would never use but you like eloquent models?

Well use slime-api for fuck sake.

Basically a boilerplate to create quickly RestFulAPI.

Ingredients

Aqua, Eloquent (from Laravel), Slim (v3), Some other bullshit

Beware, it might contain nuts

HowTo

First clone the project

git clone git@github.com:vikkio88/slime.git

or install with composer

composer create-project vikkio88/slime-api WHATEVER

Install the dependencies (not needed if you used create-project command above)

composer install

Move and edit the configuration from the file .env.example to the file .env

Run the migrations and seeders

php novice migrate && php novice seeder

Run the tests

phpunit

Novice

novice is a php cli script taken from another project. In this small project I extended it to make it easier for everyone to generate classes and even generate their own commands.

How to

Novice will run a script which is in the right place, if it extends the right Interface. The file config/console contains the path where novice will search for the scripts

return [
    'commandPaths' => [
        'App\Lib\Slime\Console\Commands\\',
        'App\Console\\'
    ]
];

If you need more, just add more (dont forget to add them to the composer json autoloader config)

Usage

To run a novice command you will need to be in the root of the project and type

$ php novice <command_name>

Command Bundled

Out of the box Slime provide you the following novice commands:

create_config <name>
create_migration <name>
create_model <name> (namespaces availabile)
create_action <name> (namespaces availabile)
create_seeder <name>
create_route <name>
migrate
seed
build

which code can be found on App\Lib\Slime\Console\Commands

and

coverage [percentage]
echo [parameter1] [parameter2] ...

which code can be found on App\Console

Build Command

Running the command php novice build you will generate a lighter version of your api project (easier to deploy via ftp) in the dist/ folder.

php novice build

Will generate the deployable version, if you want it to be execute with verbose output just add -v

php novice build clean

will clean the dist/ folder.

There is one configuration file that will allow you to customize your build config/build.php You can add to this file the folders and the files you want the build script to copy over, and if you want to exclude more files on the vendor clean process.

Namespaced Generator Commands

php novice create_model users\\player

Will generate a Model inside the right folder, creating the namespace structure (psr4 standard) and the namespace string on the file head. the command above will generate Models/Users/Player.php file and the class will be in the namespace App\Models\Users.

php novice create_action users\\player_get_one

Will generate an Action inside the right folder, creating the namespace structure (psr4 standard) and the namespace string on the file head. the command above will generate Actions/Users/PlayerGetOne.php file and the class will be in the namespace App\Actions\Users.

All the Generator commands convert snake_case into UpperCamelCase, so if you type

php novice create_model users\\player_match

the command above will generate Models/Users/PlayerMatch.php file and the class will be in the namespace App\Models\Users.