Kotchasan Framework Documentation

Kotchasan Framework Documentation

Kotchasan Framework Documentation

EN 06 Feb 2026 13:10

Kotchasan Framework Documentation

Kotchasan Framework is a powerful and flexible PHP framework designed for developing high-performance web applications. It supports multiple database systems including MySQL, PostgreSQL, MSSQL, and SQLite.

Framework Overview

Kotchasan Framework features:

  • MVC Architecture - Clear architectural pattern
  • Database Abstraction - Support for multiple database types
  • Security First - Built-in security features
  • Performance Optimized - Designed for high performance
  • Developer Friendly - Easy to use and learn

Getting Started Guides

📚 Essential Guides

🏗️ Architecture and Patterns

API Reference

🗄️ Database System

🔗 Database Connections

🚀 Cache System

🌐 HTTP and Web

🔐 Security and Authentication

📝 Forms and Validation

🛠️ Tools and Utilities

📧 Communication and Export

  • Email - Email sending
  • Pdf - PDF generation
  • Csv - CSV handling
  • Curl - HTTP Client
  • Barcode - Barcode generation

🌍 Localization and Regional

📋 Logging and Monitoring

Installation

System Requirements

  • PHP 7.4 or higher
  • Web Server (Apache, Nginx)
  • Database (MySQL, PostgreSQL, MSSQL, or SQLite)
  • Composer

Installation via Composer

  1. Download files from GitHub
  2. Extract files to your web directory
  3. Set write permissions for datas/ folder
composer create-project kotchasan/kotchasan myproject
cd myproject

Initial Configuration

// settings/database.php
return [
    'default' => [
        'driver' => 'mysql',
        'host' => 'localhost',
        'database' => 'mydatabase',
        'username' => 'root',
        'password' => 'password',
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
    ]
];

Basic Usage

Creating Database Instance

use Kotchasan\Database;

// Create database instance
$db = Database::create();

// Fetch data
$users = $db->select('*')
    ->from('users')
    ->where('status', '=', 'active')
    ->execute();

Creating Controller

namespace MyApp\Home;

use Kotchasan\Http\Request;

class Controller extends \Kotchasan\Controller
{
    public function render(Request $request)
    {
        $view = new View();
        return $view->render();
    }
}

Creating Model

namespace MyApp\User;

use Kotchasan\Model;

class Model extends \Kotchasan\Model
{
    protected $table = 'users';

    public function getAllUsers()
    {
        return $this->db->select('*')
            ->from($this->table)
            ->where('status', '=', 'active')
            ->execute();
    }
}

Usage Examples

CRUD Operations

use Kotchasan\Database;

$db = Database::create();

// Create
$userId = $db->insert('users')
    ->values([
        'name' => 'John Doe',
        'email' => 'john@example.com'
    ])
    ->execute();

// Read
$user = $db->select('*')
    ->from('users')
    ->where('id', '=', $userId)
    ->first();

// Update
$db->update('users')
    ->set(['name' => 'Jane Doe'])
    ->where('id', '=', $userId)
    ->execute();

// Delete
$db->delete('users')
    ->where('id', '=', $userId)
    ->execute();

Using Cache

use Kotchasan\Cache\FileCache;

$cache = new FileCache(['path' => ROOT_PATH . '/datas/cache/']);

// Store cache
$cache->set('user_list', $users, 3600);

// Retrieve cache
$cachedUsers = $cache->get('user_list');

Transactions

$db->beginTransaction();

try {
    $db->insert('users')->values(['name' => 'John'])->execute();
    $db->update('accounts')->set(['balance' => 100])->execute();

    $db->commit();
} catch (\Exception $e) {
    $db->rollback();
    throw $e;
}

Error Handling

use Kotchasan\Exception\DatabaseException;

try {
    $result = $db->select('*')->from('users')->execute();
} catch (DatabaseException $e) {
    echo "Error: " . $e->getMessage();
    echo "SQL: " . $e->getQuery();
}

Additional Resources

Support

If you need help:

  1. Read this documentation and FAQ
  2. Search in the user community
  3. Create an Issue on GitHub
  4. Contact the development team

Note: This documentation is updated for the latest version of Kotchasan Framework. If you find errors or want to add information, please let us know.