Slime (SLIM + Eloquent)
, (*1)
Laravel is as heavy as a pregnant morbidly obese hippo and full of things that you would never use but you like eloquent models?, (*2)
Well use slime-api for fuck sake., (*3)
Basically a boilerplate to create quickly RestFulAPI., (*4)
Ingredients
Aqua, Eloquent (from Laravel), Slim (v3), Some other bullshit, (*5)
Beware, it might contain nuts, (*6)
HowTo
First clone the project, (*7)
git clone git@github.com:vikkio88/slime.git
or install with composer, (*8)
composer create-project vikkio88/slime-api WHATEVER
Install the dependencies (not needed if you used create-project
command above), (*9)
composer install
Move and edit the configuration from the file .env.example
to the file .env
, (*10)
Run the migrations and seeders, (*11)
php novice migrate && php novice seeder
Run the tests, (*12)
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., (*13)
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, (*14)
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), (*15)
Usage
To run a novice
command you will need to be in the root of the project and type, (*16)
$ php novice <command_name>
Command Bundled
Out of the box Slime provide you the following novice commands:, (*17)
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
, (*18)
and
coverage [percentage]
echo [parameter1] [parameter2] ...
which code can be found on App\Console
, (*19)
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., (*20)
php novice build
Will generate the deployable version, if you want it to be execute with verbose output just add -v, (*21)
php novice build clean
will clean the dist/
folder., (*22)
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., (*23)
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
., (*24)
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
., (*25)
All the Generator commands convert snake_case into UpperCamelCase, so if you type, (*26)
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
., (*27)