Kapi
Slim Framework based simple helper to generate RESTful API's and applications, requires PHP 7.
Install / Use
/learn @emir/KapiREADME
KAPI: Doors for PHP - v1.0.0
Slim Framework based simple helper to generate RESTful API's and applications, requires PHP 7.
KAPI means "door" in Turkish.
Creating a Project skeleton
git clone https://github.com/emir/kapi myproject
cd myproject
composer install
It will create an example project.
Edit Configuration
$EDITOR .env
Migrations
phinx migrate
Running the Project
cd myproject
php -S localhost:8080 -t public
That's all! :)
Getting Started
You should define your URLs in routes.php:
# src/routes.php
<?php
$urls = [
['get', '/books', 'BooksController::index', 'List all books.']
];
Create your models:
# src/Models/Book.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Book extends Model
{
/**
* @var array
*/
protected $guarded = [];
}
Create your Controllers and methods:
# src/Controllers/BooksController.php
<?php
namespace App\Controllers;
use App\Models\Book;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\QueryException;
use Slim\Http\Request;
use Slim\Http\Response;
class BooksController extends AbstractController
{
/**
* @param Request $request
* @param Response $response
* @return Response
*/
public function index(Request $request, Response $response): Response
{
$books = Book::all();
return $response->withJson($books);
}
}
Done!
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
