idler8 / laravel-just-it
Rapid development kit for application interfaces based on Laravel
Requires
- laravel/framework: ^11.0
This package is not auto-updated.
Last update: 2025-06-21 09:06:15 UTC
README
Introduction
Rapid development toolkit for application programming interfaces based on Laravel.
Use it to avoid repetitive CRUD development and not hinder your normal development habits.
Use it to generate standard documentation for your API.
Getting Started
composer require idler8/laravel-just-it
Route::middleware('api') ->namespace('Justit') ->prefix('r') ->group(function () { Route::get("/", function(){ $apis = \Justit\ApiDocument::document('api'); $resources = \Justit\Resource::document(); return [ 'apis' => $apis,'resources'=> $resources]; }); Route::post("{name}", "Controller@store"); Route::delete("{name}/{id}", "Controller@destroy"); Route::put("{name}/{id}", "Controller@update"); Route::get("{name}/{id}", "Controller@show"); Route::get("{name}", "Controller@index"); Route::get("{name}/{pre_page}/{page}", "Controller@paginate"); });
For the configuration of Route, please refer to the official documentation of Laravel
/** * This method is used to extract API documentation * Methods without general annotations will not be extracted */ dd(\Justit\ApiDocument::document('api'/** prefix of middleware */)); [[ "key" => "Controller@method", "name" => "From the first line of the general comment on the method", "describe" => "From the latter line of the general comment on the method", "parameters" => [[ "key" => "The first part from @param", "name" => "The latter part from @param" ]], "urls" => ["METHOD:uri"] ]] /** * This method extracts Model class documents from all app/Models directories * Classes that are not Model or have no general annotations will not be extracted */ dd(\Justit\Resource::document('App\\Models\\'/** prefix of namespace */)); [[ "key" => "Name of Model (using. instead of subfolders delimiter)", "name" => "From the first line of the general comment on the class", "describe" => "From the latter line of the general comment on the class", "parameters" => [[ "key"=>"Data table field names", "name"=>"Data table field comments" ],[ "key"=>"(:)prefix to scope name", "name"=>"Function Comments" ],[ "key"=>"-/+", "name"=>"Special parameters" ]], "relations" => [[ "key"=>"The name of the method that will explicitly output a Relation(hasOne/hasMany)", "name"=>"Function Comments " ]] ]] /** * Retrieve all resource data */ Http::get('/r/{resource.key}?key=value'); /** * Retrieve resource pagination data */ Http::get('/r/{resource.key}/{per_page}/{page}?key=value'); /** * Retrieve single resource pagination data */ Http::get('/r/{resource.key}/{id/+/-}?key=value'); /** * Destroy single resource pagination data */ Http::delete('/r/{resource.key}/{id/+/-}?key=value'); /** * Update single resource pagination data * Query is only used for retrieval */ Http::put('/r/{resource.key}/{id/+/-}?key=value',['key'=>'value']); /** * Insert single resource pagination data */ Http::post('/r/{resource.key}',['key'=>'value');
For more practical methods, please refer to the source code or test cases
Test Environment
# Run a Docker testing environment docker run --rm -it -v $PWD:/app $(docker build -f ./docker/Dockerfile . -q) # Copy test cases & Run test php artisan justit
If files in the docker directory are deleted, it is recommended to restart the Docker based testing environment.
License
Laravel Just it is open-sourced software licensed under the MIT license.
Why develop it
This is one of the achievements of my years of development experience. I have used it in many projects and it has helped me develop multiple new full stack projects simultaneously in a very short period of time. I included it in my college graduation thesis, but my teacher criticized it as useless. I want to know the public's opinion on this, so I put it here.