2025-12-22 23:42:04 +08:00
e
2022-01-09 03:50:38 +08:00
eee
2025-12-18 22:53:28 +08:00
eee
2023-12-12 14:09:11 +08:00
eee
2023-12-01 22:57:25 +08:00
e
2022-01-09 03:50:38 +08:00
eee
2025-12-22 23:42:04 +08:00
eee
2025-12-18 22:35:21 +08:00
eee
2025-12-18 15:39:47 +08:00
e
2022-01-09 03:50:38 +08:00
eee
2024-09-11 15:22:25 +08:00
2025-12-22 13:38:31 +00:00
2025-12-22 13:38:31 +00:00
eee
2025-12-01 06:39:05 +08:00
eee
2025-12-01 06:39:05 +08:00

Kiri Core Framework Documentation

Project Introduction

Kiri is a high-performance PHP-based core framework designed to provide developers with a simple and efficient development experience. The framework includes a variety of practical utility classes, exception handling mechanisms, configuration management, and a dependency injection container, making it suitable for building various types of applications.

Key Features

  • Dependency Injection Container: Provides powerful dependency management via Kiri\Di\Container.
  • Configuration Management: Supports reading configuration from files and environment variables.
  • Exception Handling: Offers a unified exception handling interface with support for registering custom exception handlers.
  • Logging: Built-in StdoutLogger supporting multiple log levels.
  • Utility Classes:
    • Str: String operations such as encryption and random string generation.
    • Json: JSON encoding/decoding and response construction.
    • Help: Auxiliary functions including XML conversion, random number generation, and email sending.
    • DateFormat: Date and time formatting tools.
  • Networking: Supports local IP retrieval and Socket programming.
  • NoSQL Support: Provides client wrappers for Redis and MongoDB with connection pool management.

Installation

System Requirements

  • PHP 7.4 or higher
  • Composer (for dependency management)

Installation Steps

  1. Ensure Composer is installed.
  2. Run the following command to install dependencies:
    composer install
    

Usage Guide

Initialize the Framework

use Kiri\Kiri;
use Kiri\Application;

// Initialize the container
Kiri::setContainer(new Container());

// Create an application instance
$app = new Application(
    new EventProvider(),
    new ConfigProvider(),
    Kiri::getContainer()
);

// Initialize the application
$app->init();

Configuration Management

Configuration files can be loaded and accessed via the ConfigProvider class:

$config = new ConfigProvider();
$databaseHost = $config->get('database.host');

Dependency Injection

Use the container to inject dependencies:

$service = Kiri::getContainer()->get(MyService::class);

Logging

Use the built-in logger to output messages:

Kiri::getLogger()->info('This is an info message.');

Exception Handling

Register a custom exception handler:

$errorHandler = new ErrorHandler();
$errorHandler->registerExceptionHandler(function (Throwable $e) {
    echo "Unhandled exception: " . $e->getMessage();
});

Database Connections

Redis

$redis = new Redis();
$redis->connect();
$redis->set('key', 'value');
echo $redis->get('key');

MongoDB

$mongo = new MongoDB();
$collection = $mongo->getCollection('users');
$result = $collection->find([]);

Utility Class Examples

String Operations

echo Str::rand(10); // Generate a random string

JSON Response

echo Json::jsonSuccess(['data' => 'example'], 'Operation successful');

Date Formatting

echo DateFormat::DaySecond(); // Get the number of seconds in a day

Contribution Guidelines

Contributions are welcome! Please follow these steps:

  1. Fork the project repository.
  2. Create a new branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Create a Pull Request

License

This project is licensed under the MIT License. For details, see the LICENSE file.

Contact

If you have any questions or suggestions, please open an Issue or contact the project maintainers.


Thank you for choosing Kiri Core Framework! We look forward to your feedback and contributions.

S
Description
No description provided
Readme MIT 5.8 MiB
v2.24 Latest
2026-07-03 10:29:27 +00:00
Languages
PHP 96.5%
HTML 3.5%