Introduction
Kipchak's Core
Kipchak uses Slim 4 to bootstrap effectively and adds formal structure around initialising Drivers and Middleware.
It als provides some HTTP Request and Response Helpers and a base Controller which uses the Logger Driver to help you get started.
Let's dig a little deeper to understand what lies at the heart of Kipchak.
How Kipchak Bootstraps
At the heart of Kipchak lies the API class and its boot() method, which is responsible for initialising Drivers and Middleware,creating the application container, and setting up the request lifecycle.
The index.php file in the html directory serves as the entry point for Kipchak applications.
It instantiates the API class and calls its boot() method to start the application.
The boot() method then:
- Creates the Slim App and injects the routing Middleware.
- Loads and initialises any drivers (which are just dependencies injected into the service container) specified in the
driversdirectory of your project. - Loads and initialises any middleware specified in the
middlewaresdirectory of your project. - Loads any routes specified in the
routesdirectory of your project.
That's it.
Kipchak itself does not contain any drivers or middleware. They are all external composer packages. You can write your own inside your project, or create a separate package and install them via composer.
Packages Included in the Core
The core repository contains the following packages:
- Slim
- PHP DI (for the service container)
- Cuyz Valinor for typed objects going in and out of your API
- Zircotte's Swagger PHP so you can generate OpenAPI documentation for your API
Drivers and Middleware
Drivers and middleware are the building blocks of Kipchak's extensibility.
They allow you to extend Kipchak's functionality without modifying its core code.
Drivers and Middleware are exposed as Interfaces in the Core so you can write your own.
The core itself does not contain any drivers or middleware but provides a framework for you to implement your own.
The starter project includes all official drivers in its composer.json file. Here's the "require" section so you can get a feel for how extensible Kipchak is:
"require": {
"php": ">=8.4",
"kipchak/core": "^2",
"kipchak/driver-couchdb": "^1",
"kipchak/driver-memcached": "^1",
"kipchak/driver-http": "^1",
"kipchak/driver-filecache": "^1",
"kipchak/driver-doctrine": "^1",
"kipchak/driver-logger": "^1",
"kipchak/driver-rabbitmq": "^1",
"kipchak/middleware-error": "^1",
"kipchak/middleware-auth-key": "^1",
"kipchak/middleware-auth-jwks": "^1",
"kipchak/middleware-subashi": "^1"
},