Skip to content

onetoneframework/framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Logo

Onetone Framework

License: GPL v3 Badge

Onetone Framework is a modern full-stack PHP platform that combines advanced backend routing, controller autowiring, an ActiveRecord ORM, CLI tooling, native FFI integrations, AI model runtime support, and a complete frontend toolset. It aims to provide a single coherent toolkit for server, native, and research workflows while remaining extensible and modular.

Table of Contents

πŸ› οΈ Installation (Docker)

Automatic installer (Windows)

Set-ExecutionPolicy RemoteSigned

./install_windows.ps1

Set-ExecutionPolicy Default

Configure dot-environment file

copy res/Platform/PHP/root/.env.example res/Platform/PHP/root/.env
code -g res/Platform/PHP/root/.env

Composer install

composer install --working-dir=./res/Platform/PHP

# optional
php php_console wizard

Composer install via phar

php ./bin/phar/composer.phar install --working-dir=./res/Platform/PHP

Docker run in development mode

copy .env.example .env
code -g .env
docker compose up -d

Publish the corejs package into verdaccio

docker compose up -d verdaccio
cd res\corejs

npm adduser --registry http://localhost:4873
npm install --registry http://localhost:4873
npm install clovercorejs --registry=http://localhost:4873

npm login --registry=http://localhost:4873
npm publish  --registry http://localhost:4873 --access public

Build frontend

cd res\frontend

# build via nodejs
npm run build

# build via vite
npm run build:vite

# build via es-build
npm run build:esbuild

πŸš€ Quick Start

Requirements

  • PHP 8.2+
  • Composer
  • Extensions: ctype, curl, dom, fileinfo, filter, gd, hash, iconv, intl, json, libxml, mbstring, mysqli, openssl, pdo, pdo_mysql, session, simplexml, spl, zip, zlib

Run (PHP built-in server)

php -S localhost:8080 -t res/Platform/PHP/root

.env Configuration

Runtime loads .env and overrides runtime options (debug/timezone/error reporting).

When ROUTE_CACHE=true, routes are cached to ROUTE_CACHE_PATH;

delete the file or set ROUTE_CACHE=false after route changes. When APP_MAINTENANCE=true, HTTP kernel returns 503.

APP_DEBUG=true
APP_TIMEZONE=Japan/Tokyo
APP_ERROR_REPORTING=32759
APP_MAINTENANCE=false
ROUTE_CACHE=true
ROUTE_CACHE_PATH=./res/Platform/PHP/root/App/Cache/routes.cache.php

MYSQL_HOST=127.0.0.1
MYSQL_USERNAME=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=database

GEMINI_API_KEY=your-key

Directory

bin
    ctranslate_ffi
    onnx_ffi
    pak
    phar
    template
    training
conf
    apache
    caddy
    cherokee
    composer
    docker
    h2o
    haproxy
    lightspeed
    mysql
    nginx
    openresty
    php
    redis
    supervisord
    sysctl
    wildfly
res
    corejs
        assets
        src
            Classes
            Component
            Filter
            Function
            Interface
            ReactComponent
            Variables
        types
    frontend
        src
            api
            assets
            common
            component
            css
            enum
            filter
            functions
            hooks
            i18n
            layouts
            page
            system
            threejs
            types
        loaders
    lib
    Platform
        Android
        Asm
        C
        C#
        C++
        CSS
        Elixir
        Flutter
        Go
        HSLS
        Java
        Nodejs
        ObjectiveC
        PHP
        Python
        Query
        QuickBMS
        R
        React-Native
        Ruby
        Rust
        Swift
        Text
        Unity
        Visual Basic 6
        Vscode
        zig

Annotation-based Controller Routing

namespace App\Controller;

use Clover\Annotation\{Prefix, Route};
use Clover\Framework\Component\BaseController;

#[Prefix('/')]
class ExampleController extends BaseController
{
    #[Route('GET', '/')]
    public function index()
    {
        return $this->responseText('Hello, Clover');
    }
}

Basic Programmatic Routing

use Clover\Classes\Routing\Router;

$router = new Router();
$router->get('/index', function () {
    return $this->responseText('This is main page');
});

Route Parameters

use Clover\Classes\Routing\Router;

$router = new Router();
$router->get('/api/{a}?:([a-z]+)/{b}?:(\d+)/{c}?:(.*)?', function ($a, $b, $c) {
    return $this->responseJson(compact('a','b','c'));
});

Route Groups

$router = new Router();
$router->group('/first', function ($route) {
    $route->get('/second', function () {
        return $this->responseText('This is main page');
    });
});

Controller Middleware

namespace App\Middleware;

use Clover\Framework\Component\Middleware;

class ExampleMiddleware
{
    public function handle($next)
    {
        return $next();
    }
}

#[Middleware(ExampleMiddleware::class)]
class ExampleController extends BaseController
{
    #[Middleware(ExampleMiddleware::class)]
    public function index()
    {
    }
}

Interceptor (Boot-time Hook)

namespace App\Interceptor;

use Clover\Classes\Routing\Router;
use Clover\Framework\Component\Response;
use Clover\Abstract\Interceptor;

class PreChangeInterceptor extends Interceptor
{
    public function postHandle(object &$handler, string &$method, array &$args, mixed &$result)
    {
        if ($handler instanceof Router && $result instanceof Response) {
            // mutate response body if needed
        }
    }
}

Configure app-level dependencies in App/Configure/dependencies.php. Example: database connection and ActiveRecord binding.

use Clover\Classes\Database\ActiveRecord;
use Clover\Classes\Database\Driver\PHPDataObject;

return [
    PHPDataObject::class => (function () {
        $db = new PHPDataObject();
        $db->setHostName($_ENV['MYSQL_HOST']);
        $db->setUsername($_ENV['MYSQL_USERNAME']);
        $db->setPassword($_ENV['MYSQL_PASSWORD']);
        $db->setDatabase($_ENV['MYSQL_DATABASE']);
        $db->createConnection();

        ActiveRecord::setDatabaseConnection($db);
        return $db;
    })()
];

Find ActiveRecord Entity

use App\Entity\Game;

$game = new Game();
$game = $game->findBy('title', 'Starcraft');

Create / Update

use App\Entity\Game;

$game = new Game();
$game->release = '1995-05-01';
$game->brand_no = 1;
$game->title = 'Starcraft';
$game = $game->save();

Relations

use Clover\Annotation\Entity;

class Entity extends ActiveRecord
{
    #[Entity\ID]
    #[Entity\Column(name:"index", type:"integer")]
    private $index;

    #[Entity\Column(name:"name", type:"string")]
    private $name;
 
    #[Entity\OneToMany(targetEntity:"App\\Entity\\OneToManyEntity", mappedBy:"parent_no")]
    private $parent_many;
    
    #[Entity\OneToOne(targetEntity:"App\\Entity\\OneToOneEntity", mappedBy:"parent_no")]
    private $parent_one;
}

Datetime

use Clover\Classes\Date\Date;

$julian = Date::toJulian(2024, 05, 07);
$this->assertEquals($julian, "2460437.5");

$datetime = Date::julianToGregorian($julian);
$this->assertEquals($datetime->format('Y-m-d'), "2024-05-07");

$lastDay = Date::getLastDayOfMonth(2024, 2);
$this->assertEquals($lastDay, "29");

$startOfWeek = Date::getStartOfWeek('2024-05-07');
$this->assertEquals($startOfWeek, "2024-05-06");

$endOfWeek = Date::getEndOfWeek('2024-05-07');
$this->assertEquals($endOfWeek, "2024-05-12");

$qurter = Date::getQuarter();
$this->assertEquals($qurter, "4.0");

$datesBetween = Date::getDatesBetween('2024-05-01', '2024-05-07');
$this->assertEquals(count($datesBetween), "7");

$relativeDayName = Date::getRelativeDayName(Date::getYesterday());
$this->assertEquals($relativeDayName, "Yesterday");

$yearsBetween = Date::getYearsBetween('2000-01-01', '2024-05-07');
$this->assertEquals(count($yearsBetween), "25");

Promise

use Clover\Classes\Event\Promise;

$promise = new Promise(function ($resolve, $reject) {
    $resolve('resolved');
});

$promise->then(function ($resolved) {
    $this->assertEquals('resolved', $resolved);
}, function ($rejected) {
    // stuff
});

Chord (Music)

use Clover\Classes\Chord\Chord;
use Clover\Classes\Chord\Interval;
use Clover\Classes\Chord\Scale;
use Clover\Classes\Chord\Tension;
use Clover\Classes\Chord\Tone;

$chord = new Chord(0, "major", 0); // C major chord in c key

$tones = $chord->getYamahaTones();
$this->assertEquals('CEG', join($tones));

$tones = $chord->getChordTones();
$this->assertEquals('047', join($tones));

$tension = new Tension(0, MusicChordType::MAJOR_7TH);
$tones = new Tone($tension->getAvailableTensions());
$tones = $tones->getYamahaTones();
$this->assertEquals('DF#A', join($tones));

$tension = new Tension(0, MusicChordType::MINOR_7TH);
$tones = new Tone($tension->getAvailableTensions());
$tones = $tones->getYamahaTones();
$this->assertEquals('DFA', join($tones));

$tension = new Tension(0, MusicChordType::DIMINISHED_7TH);
$tones = new Tone($tension->getAvailableTensions());
$tones = $tones->getYamahaTones();
$this->assertEquals('C#DD#F#G#A', join($tones));

$tension = new Tension(0, MusicChordType::MINOR_7TH_FLAT_5);
$tones = new Tone($tension->getAvailableTensions());
$tones = $tones->getYamahaTones();
$this->assertEquals('C#DF', join($tones));

$scale = new Scale(0);
$tones = new Tone($scale->getScale());
$tones = $tones->getYamahaTones();
$this->assertEquals('CDEFGAB', join($tones));

$scale = new Scale(0, MusicScaleType::PENTATONIC);
$tones = new Tone($scale->getScale());
$tones = $tones->getYamahaTones();
$this->assertEquals('CDEGA', join($tones));

$interval = new Interval(0, 10);
$this->assertEquals('792.0', $interval->getHertz());

$chord = new Chord(8, "french6", 0); // Ab
$tones = $chord->getYamahaTones();
$this->assertEquals('G#CDF#', join($tones));

$chord = new Chord(8, "german6", 0); // Ab
$tones = $chord->getYamahaTones();
$this->assertEquals('G#CD#F#', join($tones));

$chord = new Chord(8, "italian6", 0); // Ab
$tones = $chord->getYamahaTones();
$this->assertEquals('G#CF#', join($tones));

$chord = new Chord(5, "tristan", 0); // F
$tones = $chord->getYamahaTones();
$this->assertEquals('FBD#G#', join($tones));

$chord = new Chord(0, "mystic", 0); // C
$tones = $chord->getYamahaTones();
$this->assertEquals('CF#A#EAD', join($tones));

$chord = new Chord(0, "synthetic", 0); // C
$tones = $chord->getYamahaTones();
$this->assertEquals('CFB', join($tones));

Data Transfer Object

use Clover\Classes\Data\DataTransferObject;

$dataTransfer = new DataTransfer();
$dataTransfer->setStore('storedText');
$store = $dataTransfer->getStore();
$this->assertEquals('storedText', $store);

$store = DataTransfer::from(['store' => 'storedStaticText']);
$store = $store->getStore();
$this->assertEquals('storedStaticText', $store);

StringObject / ArrayObject

use Clover\Classes\Data\ArrayObject;
use Clover\Classes\Data\CardNumberObject;
use Clover\Classes\Data\EmailObject;
use Clover\Classes\Data\HTMLObject;
use Clover\Classes\Data\StringObject;

$string = new CardNumberObject('4539148803436467');
$this->assertTrue($string->isVisa());
$this->assertTrue($string->isValidate());

$string = new HTMLObject('<a>https://www.google.com</a>');
$this->assertEquals('<a><a href="https://www.google.com">https://www.google.com</a></a>', $string->autolink());

$domain = new EmailObject('clover@naver.com');
$this->assertTrue($domain->isKnownDomain());
$this->assertEquals("naver.com", $domain->getDomain());

$domain = new EmailObject('clover@gmail.com');
$this->assertEquals("gmail.com", $domain->getDomain());
$this->assertTrue($domain->isKnownDomain());

$this->assertEquals('This is text for testing!!', $string->append('!!'));
$this->assertEquals('Notice: This is text for testing!!', $string->prepend('Notice: '));
$this->assertEquals('**Notice: This is text for testing!!**', $string->appendBoth('**'));
$this->assertEquals('Intel', $string->set('Intel Computer')->cut(5));
$this->assertEquals('CloverFramework', $string->set('Clover Framework')->camelize());
$this->assertEquals('clover-framework', $string->set('Clover Framework')->slugify());
$this->assertEquals('Clover framework', $string->set('clover framework')->capitalizeFirstLetter());
$this->assertNotEquals('abcdefghijklmnopqrstuvwxynz', $string->set('abcdefghijklmnopqrstuvwxynz')->shuffle());
$this->assertEquals('Clover Framework', $string->set('  Clover Framework  ')->trim());
$this->assertEquals('  Clover Framework', $string->set('  Clover Framework')->trimEnd()->getRawData());
$this->assertEquals('CLOVER FRAMEWORK', $string->set('Clover Framework')->toUpperCase()->getRawData());
$this->assertEquals('clover framework', $string->set('Clover Framework')->toLowerCase()->getRawData());
$this->assertEquals('krowemarF revolC', $string->set('Clover Framework')->reverse()->getRawData());
$this->assertEquals('AAAAAAAAAA', $string->set('A')->repeat(10)->getRawData());
$this->assertEquals(15, $string->set('Clover Framework')->similar('Closer Framework'));
$this->assertEquals('C*o*e* *r*m*w*r*', $string->set('Clover Framework')->replaceEven('*')->getRawData());
$this->assertEquals('*l*v*r*F*a*e*o*k', $string->set('Clover Framework')->replaceOdd('*')->getRawData());
$this->assertEquals('Clov********work', $string->set('Clover Framework')->replaceCenter('*******')->getRawData());
$this->assertEquals('Cl*******Framework', $string->set('Clover Framework')->replaceSubstr('*******', 2, 5)->getRawData());
$this->assertEquals('Clover Framework Unit Test', $string->set('Clover Framework')->concat(' Unit Test')->getRawData());
$this->assertEquals(2, $string->set('Clover Framework')->wordCount());

$expected = [
    ["index" => 0, "start" => 1, "pattern" => "ATG"],
    ["index" => 2, "start" => 6, "pattern" => "TAC"],
    ["index" => 4, "start" => 13, "pattern" => "ACT"],
    ["index" => 1, "start" => 16, "pattern" => "GCT"],
    ["index" => 1, "start" => 32, "pattern" => "GCT"],
    ["index" => 0, "start" => 35, "pattern" => "ATG"],
    ["index" => 4, "start" => 38, "pattern" => "ACT"],
    ["index" => 2, "start" => 48, "pattern" => "TAC"],
];
$this->assertEquals($expected, $string->set('ATGCGTACCTGAACTGCTTAGCGGATCCTAGGCTATGACTGGAATCGTAC')->ahoCorasick(["ATG", "GCT", "TAC", "CGA", "ACT"])->getRawData());

$string = new StringObject('630907-2458061');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$string = new StringObject('680204-1531257');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$string = new StringObject('041215-1116529');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$string = new StringObject('041215-1116529');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$string = new StringObject('250619-1373084');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$string = new StringObject('241016-1343636');
$this->assertTrue($string->isValidResidentRegistrationNumberInKorea());

$array = new ArrayObject(['a', 'b', 'c', 'd', 'e']);
$this->assertEquals(5, $array->count());
$this->assertEquals('abcde', $array->join(''));
$this->assertEquals('e', $array->last());
$this->assertEquals('a', $array->first());
$this->assertEquals('abcdef', $array->add('f')->join(''));

$array = new ArrayObject(['a' => ['a' => '1', 'b' => '2', 'c' => ['3']], 'b' => ['a' => '1', 'b' => '2']]);
$this->assertEquals(2, $array->getMaxDepth());

Seeder

use Clover\Classes\Hash\Seeder;

$this->assertEquals(50, Seeder::splitmix32('4294967296')());
$this->assertEquals(3524489345, Seeder::mulberry32('4294967296')());
$this->assertEquals(269516800, Seeder::xorShift32('4294967296')());
$this->assertEquals(4648317627024801792, Seeder::xorShift64('4294967296')());
$this->assertEquals(1013904223, Seeder::lcg32('4294967296')());
$this->assertEquals(2357136044, Seeder::mt19937('4294967296')());
$this->assertEquals(32832, Seeder::xorshift128plus('4294967296', '4294967296')());
$this->assertEquals(2864236472, Seeder::kiss32('4294967296')());
$this->assertEquals(-6894309674753433488, Seeder::well512(4294967296)());
$this->assertEquals(2864236472, Seeder::kiss32('4294967296')());
$this->assertEquals(-8005730821889151934, Seeder::aesCtrRng('4294967296', '4294967296')());
$this->assertEquals(1750100827, Seeder::tinymt32('4294967296')());
$this->assertEquals(770165546, Seeder::well512a(4294967296)());
$this->assertEquals(337713548, Seeder::mwc256(4294967296)());
$this->assertEquals(7751050468622527276, Seeder::hmac_drbg_sha256(4294967296)());
$this->assertEquals(32, Seeder::pcg32(4294967296)());
$this->assertEquals(2357136044, Seeder::sfmt19937(4294967296)());
$this->assertEquals(614132185350056339, Seeder::chacha20_rng('4294967296', '4294967296')());

Reflection

use Clover\Classes\Reflection\Handler as ReflectionHandler;

$this->assertEquals('int', ReflectionHandler::getClassPropertyMetadata($this->reflectiveClass)->get(0)->get('type'));
$this->assertEquals('intProperty', ReflectionHandler::getClassInnerVariables($this->reflectiveClass)['intProperty']->getName());
$this->assertEquals('MagicMethod', ReflectionHandler::getInheritanceChain($this->reflectiveClass)[0]);
$this->assertEquals(true, ReflectionHandler::isMethodFinal($this->reflectiveClass, 'final'));
$this->assertEquals('bool', ReflectionHandler::getMethodReturnType($this->reflectiveClass, 'test'));
$this->assertEquals(1, ReflectionHandler::getPropertyValue($this->reflectiveClass, 'intProperty'));
$this->assertEquals('private', ReflectionHandler::getVisibility($this->reflectiveClass, 'intProperty'));
$this->assertEquals('MagicMethod', ReflectionHandler::getParentClass($this->reflectiveClass));
$this->assertEquals('a', ReflectionHandler::getMethodParameterNames($this->reflectiveClass, 'parameterCountOfMethod', false)[0]->getName());
$this->assertEquals(true, ReflectionHandler::isSubClassOf($this->reflectiveClass, 'MagicMethod'));
$this->assertEquals(false, ReflectionHandler::isMethodExists($this->reflectiveClass, 'nonExistMethod'));
$this->assertEquals(false, ReflectionHandler::hasDefaultValue($this->reflectiveClass, 'nonDefaultProperty'));
$this->assertEquals('intProperty', ReflectionHandler::getProperty($this->reflectiveClass, 'intProperty')->getName());
$this->assertEquals('test', ReflectionHandler::getMethodByName($this->reflectiveClass, 'test')->getName());
$this->assertEquals('__call', ReflectionHandler::getAvailableMagicMethodsInParentClass($this->reflectiveClass)[0]);
$this->assertEquals('intProperty', ReflectionHandler::getClassPropertiesNames($this->reflectiveClass)[0]);
$this->assertEquals(2, ReflectionHandler::getRequiredParametersCountOfClassMethod($this->reflectiveClass, 'requriedCountOfMethod'));
$this->assertEquals(3, ReflectionHandler::getParametersCountOfClassMethod($this->reflectiveClass, 'parameterCountOfMethod'));
$this->assertEquals('ReflectiveClass', ReflectionHandler::getClassShortName($this->reflectiveClass));
$this->assertEquals('ReflectiveClass', ReflectionHandler::getClassBasename($this->reflectiveClass));

PasswordHash

use Clover\Classes\Hash\PasswordHash;

$key = 'p@jdio7839!!';

$hash = PasswordHash::bcryptHash($key);
$this->assertEquals(PasswordHash::verify($key, $hash), $hash);

$hash = PasswordHash::argon21Hash($key);
$this->assertEquals(PasswordHash::verify($key, $hash), $hash);

$hash = PasswordHash::argon2IdHash($key);
$this->assertEquals(PasswordHash::verify($key, $hash), $hash);

$hash = PasswordHash::defaultHash($key);
$this->assertEquals(PasswordHash::verify($key, $hash), $hash);

ObfuscatedUUID

use Clover\Classes\UUID\ObfuscatedUUID;

ObfuscatedUUID::setSalt('test-salt');
$encode = ObfuscatedUUID::encode('123e4567-e89b-12d3-a456-426614174000');
$decode = ObfuscatedUUID::decode($encode);
$this->assertEquals('123e4567-e89b-12d3-a456-426614174000', $decode);

Encrypt

use Clover\Classes\Crypt\AES256CBC;
use Clover\Classes\Crypt\AES128CBC;
use Clover\Classes\Crypt\DESEDE3;

$encrypt = AES256CBC::encrypt('aywio&@siosP', 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');
$decrypt = AES256CBC::decrypt($encrypt, 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');

$this->assertEquals($decrypt, "aywio&@siosP");

$encrypt = AES128CBC::encrypt('aywio&@siosP', 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');
$decrypt = AES128CBC::decrypt($encrypt, 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');

$this->assertEquals($decrypt, "aywio&@siosP");

$encrypt = DESEDE3::encrypt('aywio&@siosP', 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');
$decrypt = DESEDE3::decrypt($encrypt, 'P4lB5jeIzH3ei1elH6rIPZqvDhEDRgYc');

$this->assertEquals($decrypt, "aywio&@siosP");

Frida IL2CPP Hooks

Fix the address using a format like this: (var nativeRVAOffset = '0xED2070') in scripts/hook_scripts.js:721

cd res/Platform/Python/frida
vi scripts/hook_scripts.js
py frida_attach.py

Music mood detection

Each file in the saved_model folder should be placed according to its mood category, such as happy, sad, or calm.

cd res/Platform/Python/mood
mkdir saved_model
py train.py
py predict.py audio.mp3

Create Custom CLI Command

namespace Command;

use Clover\Implement\CommandInterface;
use Clover\Classes\CLI\Input;
use Clover\Classes\CLI\InputOption;

class ExampleCommand implements CommandInterface
{
    public array $options = [];

    public function getName(): string { return 'example'; }
    public function getDescription(): string { return 'Example Command Line'; }

    public function configure(): void
    {
        $this->options[] = new InputOption('prompt', 'Prompt', 'This is input option');
    }

    public function run(Input $input): bool
    {
        echo 'Hello World';
        return true;
    }
}

CTranslate2 (HuggingFace)

use Clover\Classes\FFI\HuggingFace;

$huggingFace = new HuggingFace();
$response = $huggingFace->callModel(
    BASE_PATH.'/en_de_ct2_model',
    BASE_PATH.'/en_de_ct2_model/source.spm',
    BASE_PATH.'/en_de_ct2_model/target.spm',
    'My computer is awesome',
    'cpu', 6, 6
);

Google Gemini

use Clover\Classes\LLM\Gemini;
use Clover\Classes\System\Output;
use Clover\Enumeration\Gemini\Model;

$prompt = 'Please make a simple python code';
$geminiClient = new Gemini\Client($_ENV['GEMINI_API_KEY'], Model::GEMINI_2_5_PRO);
$response = $geminiClient->requestPrompt($prompt);

Output::print($response->hasError() ? $response->getError()->getMessage() : $response->getText());

Alsong Lyrics

use Clover\Plugin\AlsongLyric;

$alsongLyric = new AlsongLyric('/example.mp3');
if ($alsongLyric->isLoaded()) {
    foreach ($alsongLyric->getLyric() as $lyric) {
        echo $lyric;
    }
} elseif (!$alsongLyric->isValidFile()) {
    echo 'Could not receive lyrics';
}

FFI (Windows)

use Clover\Classes\FFI\Windows\WindowsAPI;

$api = new WindowsAPI();
$api->createNewWindow('New Windows', 500, 500, 2000, 500);

Parse UserAgent

use Clover\Classes\HTTP\Request;

$parsedUserAgent = Request::parseUserAgent('Mozilla/5.0 (...)');
// $parsedUserAgent['device_version'], ['operation'], ['device'], ['browser'], ['browser_version']

XHR Request (CoreJS excerpts)

import { RequestService } from 'clovercorejs';
const xhr = RequestService.xhr('GET', `/api`, '');

xhr.onload = function () {
    try {
        const response = JSON.parse(this.responseText);
        setData(response.pages);
        setCurrentPage(response.page);
        setTotalPages(response.count);
    } catch (error) {
        console.error('JSON parsing error:', error);
    }
    setLoading(false);
};

Pagination

import Paginator from '@component/Paginator';

const PageRenderer = ({ type }) => {
    const navigate = useNavigate();
    const [currentPage, setCurrentPage] = useState(1);
    const [totalPages, setTotalPages] = useState(20);

    const handlePageClick = (page: number) => {
        navigate(`/page/${page}`);
    };

    useEffect(() => {
        // fetch page data
    }, [currentPage]);

    return &lt;Paginator currentPage={currentPage} totalPages={10} documentCountPerPage={24} totalDocumentCount={totalPages} onClick={handlePageClick} /&gt;;
};

GoogleMap

import { GoogleMap } from '@component/GoogleMap';

return (
    <GoogleMap apiKey="~~"></GoogleMap>
)

Read file contents by onetone rust lib

use std::path::PathBuf;

mod lib;

fn main() {
    let path = lib::filesystem::get_current_dir().unwrap();
    let file_path = path.join("src").join("main.rs");
    let result = lib::filesystem::read_file_to_string(file_path);
    
    match result {
        Ok(content) => println!("File content:\n{}", content),
        Err(e) => println!("Failed to read file: {}", e),
    }
}

Three.js 3D Rendering

export const mapData = MapData = {
    IGLBs: [{
        name: "lamp",
        asset: lamp,
        type: "scene",
        scale: {
            x: 1.0, y: 1.0, z: 1.0
        },
        position: {
            x: 0, y: 0, z: 0
        },
        preinstall: true
    },
        {
            name: "venueStage",
            asset: lowpoly_stylized_classroom,
            type: "scene",
            scale: {
                x: 1.5, y: 2.5, z: 1.5
            },
            position: {
                x: 0, y: 0, z: 0
            },
            preinstall: true
        },
    ],
    bgm: {
        asset: WHITE,
        irAudio: {
            enable: true
        },
        volume: 0.1,
        lowshelf: {
            enable: true
        },
        lowpass: {
            enable: true
        },
        resonanceAudio: {
            enable: true
        }
    },
    sounds: [
        {
            name: "clickSound",
            asset: clickSound
        },
        {
            name: "elevatorButton",
            asset: elevatorButtonSound
        },
        {
            name: "elevatorComplete",
            asset: elevatorCompleteSound
        },
        {
            name: "elevatorDoorOpen",
            asset: elevatorDoorOpenSound
        },
        {
            name: "elevatorDoorClose",
            asset: elevatorDoorCloseSound
        }
    ],
    physical: "manual",
    characterProperty: {
        castShadow: true
    },
    cameraProperty: {
        type: "perspective",
        fixed: false,
        angle: CameraAngleType.FREE,
        fov: 60,
        near: 0.005,
        far: 1000
    },
    hud: {
        available: true
    },
    characterAsset: character,
    terrains: [
        {
            width: 20,
            height: 20,
            widthSegments: 100,
            heightSegments: 100,
            color: 0x548B54,
            obstacles: true,
            position: {
                x: 0,
                y: 0,f
                z: 0
            }
        }
    ],
    grounds: [
        {
            kind: "ground",
            width: 100,
            height: 100,
            texture: bush,
            widthSegments: 1,
            heightSegments: 1,
            obstacles: true,
            position: { x: 0, y: 0, z: 0 },
            physicsAttributes: {
                movable: false,
                position: { x: 0, y: 0, z: 0 },
                collidable: true
            }
        }
    ],
    videos: [
        {
            src: 'https://www.youtube.com/embed/4EwFJGWPaWU',
            muted: false,
            playOnStart: false,
            obstacles: true,
            width: 35.915594856646734,
            height: 23.883538228861,
            x: -0.15,
            y: 9.43,
            z: -15.65,
            irAudio: {
                enable: true,
                source: omni
            },
            resonanceAudio: {
                enable: true
            },
            physicsAttributes: {
                movable: true,
                position: {
                    x: -0.61,
                    y: 5.56,
                    z: -15.49,
                },
                receiveShadow: true,
                castShadow: true
            }
        }
    ],
    boxes: [
        {
            size: { width: 2, height: 2, depth: 2 },
            position: {
                x: 0, y: 2, z: 0
            },
            texture: greenWoodTexture,
            physicsAttributes: {
                movable: true,
                collidable: false,
                position: {
                    x: 10, y: 1, z: 10
                },
                receiveShadow: true,
                castShadow: true
            },
            obstacles: true
        },
        {
            size: { width: 2, height: 2, depth: 2 },
            position: {
                x: 0, y: 2, z: 0
            },
            texture: greenWoodTexture,
            physicsAttributes: {
                movable: true,
                collidable: false,
                position: {
                    x: 20, y: 0, z: 20
                },
                receiveShadow: true,
                castShadow: true
            },
            obstacles: true
        },
        {
            size: { width: 2, height: 2, depth: 2 },
            position: {
                x: 0, y: 2, z: 0
            },
            texture: greenWoodTexture,
            physicsAttributes: {
                movable: true,
                collidable: false,
                position: {
                    x: 30, y: 0, z: 30
                },
                receiveShadow: true,
                castShadow: true
            },
            obstacles: true
        },
    ],
    lights: [
        {
            type: "light",
            lightType: "ambient",
            intensity: 1.5,
            position: {
                x: 0,
                y: 0,
                z: 0,
            },
            color: 0xffffff
        }
    ]
    elevators: [
        {
            position: { x: 0, y: 0, z: 0 },
            width: 10,
            height: 10,
            depth: 10,
            wallThickness: 0.1,
            wallMaterial: {
                type: "standard",
                side: THREE.DoubleSide,
                texture: {
                    asset: smoothStoneTexture,
                    sWrap: "repeat",
                    tWrap: "repeat",
                    filter: "nearest"
                }
            },
            physicsAttributes: {
                movable: false,
                position: { x: 0, y: 0, z: 0 },
                collidable: false,
                fixed: false
            }
        }
    ]
};

Create Windows Application

#include <stdio.h>
#include <windows.h>
#include <winsock2.h>
#include <tchar.h>
#include "file_system.h"
#include "network_windows.h"
#include "datetime.h"
#include "windows.h"
#include "audio_windows.h"
#include <conio.h>
#include <mmsystem.h>
#include <shellapi.h>
#include <shlwapi.h>

const char g_szClassName[] = "exampleWindowClass";

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
	if (!is_running_as_admin()) {
        if (relaunch_as_admin() == 0) {
            return 0;
        } else {
            MessageBox(NULL, "Need admin approval", "Permission Denined", MB_ICONERROR);
            return 1;
        }
    }
	
	HWND hwnd;
	MSG msg;
	WNDCLASS WndClass;

	// Registering the Window Class
	WndClass.style = CS_HREDRAW | CS_VREDRAW;	
	WndClass.lpfnWndProc = WndProc;	
	WndClass.cbClsExtra = 0;
	WndClass.cbWndExtra = 0;
	WndClass.hInstance = hInstance;
	WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	WndClass.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(255, 255, 255));
	WndClass.lpszMenuName = NULL;	
	WndClass.lpszClassName = g_szClassName;

	if (!RegisterClass(&WndClass))
    {
		return 0;
	}

	hwnd = create_general_window(hInstance, "exampleWindowClass", "Sample Windows");
	if(hwnd == NULL)
    {
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	// The Message Loop
	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int)msg.wParam;
}

// Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;

	HMENU hMenu, hSubMenu;
	HICON hIcon, hIconSm;

	HWND hTextbox;
	RECT rcClient;

	switch (iMsg)
	{
		case WM_SIZE:
			GetClientRect(hwnd, &rcClient);
    		SetWindowPos(hTextbox, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);

			break;
        case WM_COMMAND:
			printf("%d", wParam);

			switch(LOWORD(wParam))
            {
				case 150:
					play_midi("black_star2.mid");
					break;
				case 160:
					enable_task_manager();
					break;
            }

			break;
		case WM_LBUTTONDOWN:
			break;
		case WM_CREATE:
			hMenu = CreateMenu();

			hSubMenu = CreatePopupMenu();
			append_menu(hSubMenu, "&SubMenu");
			append_menu_with_tag(hSubMenu, "&PlayMidi", 150);
			append_menu_with_sub(hMenu, "&FirstMenu", hSubMenu);
			append_menu_with_tag(hSubMenu, "&DownloadImage", 160);

			SetMenu(hwnd, hMenu);

			hTextbox = create_textbox(hwnd);

			GetClientRect(hwnd, &rcClient);
    		SetWindowPos(hTextbox, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);

			break;
		case WM_PAINT:
			hdc = BeginPaint(hwnd, &ps);
			
			paint_text(hdc, hwnd, ps, "TEXT", 0, 0);
			paint_text(hdc, hwnd, ps, "TEXT", 0, 100);
			
			EndPaint(hwnd, &ps);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
	}
  
	return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

Shannon Entropy

$probabilities = ['0.5', '0.5'];
$expectedEntropy = '1.00000000000000000000';
$actualEntropy = AdvancedMathBCMath::shannonEntropy($probabilities);
$this->assertEqualsWithDelta((float)$expectedEntropy, (float)$actualEntropy, 0.000000000000000001);

$probabilities2 = ['0.8', '0.2'];
$expectedEntropy2 = '0.72192809488736234787';
$actualEntropy2 = AdvancedMathBCMath::shannonEntropy($probabilities2);
$this->assertEqualsWithDelta((float)$expectedEntropy2, (float)$actualEntropy2, 0.000000000000000001);

GaussSeidel

$A = [
    ['4', '1'],
    ['1', '3'],
];
$b = ['5', '5'];
$initialGuess = ['0', '0'];
$tolerance = '1e-15';
$expectedSolution = ['0.90909090909641496305', '1.36363636363452834565'];
$actualSolution = AdvancedMathBCMath::gaussSeidel($A, $b, $initialGuess, 10000, $tolerance);

JacobiIteration

$A = [
    ['4', '1'],
    ['1', '3'],
];
$b = ['5', '5'];
$initialGuess = ['0', '0'];
$tolerance = '1e-15';
$expectedSolution = ['0.90909090907622676519', '1.36363636361434014779'];
$actualSolution = AdvancedMathBCMath::jacobiIteration($A, $b, $initialGuess, 100, $tolerance, 20);

LagrangePolynomial

$xData = ['1', '2', '3'];
$yData = ['1', '4', '9'];
$x = '2.5';
$expectedY = '6.25000000000000000000';
$actualY = AdvancedMathBCMath::lagrangePolynomial($xData, $yData, $x, 20);

NewtonInterpolation

$xData = ['1', '2', '3'];
$yData = ['1', '4', '9'];
$x = '2.5';
$expectedY = '6.25000000000000000000';
$actualY = AdvancedMathBCMath::newtonInterpolation($xData, $yData, $x, 20);

GoldenSectionSearch

$func = function ($x) {
    return AdvancedMathBCMath::bcadd(AdvancedMathBCMath::bcmul($x, $x, 20), AdvancedMathBCMath::bcmul('-5', $x, 20), 20); // f(x) = x^2 - 5x
};
$a = '0';
$b = '10';
$tolerance = '1e-10';
$expectedMin = '2.50000000008081989390';
$actualMin = AdvancedMathBCMath::goldenSectionSearch($func, $a, $b, $tolerance, 100, 20);

SolveLinearSystemLU

$A = [
    ['2', '1'],
    ['1', '-1'],
];
$b = ['3', '0'];
$expectedSolution = ['1.00000000000000000000', '1.00000000000000000000'];
$actualSolution = AdvancedMathBCMath::solveLinearSystemLU($A, $b, 20);

CramersRule

$A = [
    ['2', '1'],
    ['1', '-1'],
];
$b = ['3', '0'];
$expectedSolution = ['1.00000000000000000000', '1.00000000000000000000'];
$actualSolution = AdvancedMathBCMath::cramersRule($A, $b, 20);

TaylorSeries

$funcValue = function (string $x): string {
    return exp((float)$x);
};
$derivatives = [
    function (string $x): string {
        return exp((float)$x);
    },
    function (string $x): string {
        return exp((float)$x);
    },
];
$result = AdvancedMathBCMath::taylorSeriesNumericalBCMath('1', '0', $funcValue, $derivatives, 3);

SurfaceIntegral

$vectorField = function (array $r): array {
    return [$r[0], $r[1], $r[2]];
};
$surface = function (string $u, string $v): array {
    return [bcmul('2', cos((float)$u)), bcmul('2', sin((float)$u)), $v];
};
$integral = AdvancedMathBCMath::surfaceIntegralNumericalBCMath($vectorField, $surface, '0', (string)pi(), '0', '2', 30, 30);

VectorDotProduct

$dotProduct = AdvancedMathBCMath::vectorDotProductBCMath(['1', '2', '3'], ['4', '5', '6']);

πŸ“¦ Project Status

Status: Alpha β€” under active development and not production-ready. Important: Do not use this repository as a production dependency. See Security section for legal and operational constraints.

⭐ Overview

Onetone provides:

A PHP core with dependency injection, autowiring, routing, and an ActiveRecord-style ORM.

Native FFI integrations for OnnxRuntime, CTranslate2, Windows WinAPI, and other C libraries.

AI integration points for LLMs, OnnxRuntime, and CTranslate2.

Frontend build pipelines supporting Webpack, Vite, and ESBuild, with optional CoreJS inclusion and WebGL/Three.js helpers.

Cross-platform interoperability utilities targeting C, C#, C++, Elixir, Flutter, Go, Java, Node.js, Objective-C, Python, R, Ruby, Rust, Swift, Unity, and legacy runtimes.

Tools for reverse engineering and security research integration such as Frida and Ghidra extensions for controlled, researcher-only workflows.

CLI utilities for common tasks and extensible event-injection components for payment and third-party integrations.

πŸ—οΈ Key Features

  • Advanced router with annotation-driven routes and middleware support.

  • Controller autowiring and dependency injection container.

  • ActiveRecord-style ORM with migration and query helpers.

  • Native extensions via PHP FFI for model inference and performance-sensitive operations.

  • Frontend scaffolding with example configs for Webpack, Vite, and ESBuild.

  • Extendable payment adapters with event injection points.

  • Research utilities and integrations kept separate and gated from the core runtime.

πŸ–₯️ Requirements

  • PHP 8.1 or later recommended.

  • Composer for dependency management.

  • Optional extensions for specific features: ffi, curl, mbstring, json, pdo (if using ORM with databases).

  • For native AI runtimes: platform-specific runtimes and shared libraries for OnnxRuntime / CTranslate2 when using those features.

πŸ›‘οΈ Security Summary

This repository contains or references datasets and tooling intended for security research. Those artifacts are sensitive and can be misused. Access to any malware dataset is restricted and not enabled by default. Do not use, download, or distribute any malware samples unless you have explicit authorization and appropriate legal and lab safeguards. See SECURITY.md for full policy.

Do not include API keys, passwords, or secrets in commits. Use environment variables and secret managers.

🀝 Contributing

Read CONTRIBUTING.md before opening issues or PRs.

All contributions must follow the code style, include tests for new features, and pass CI checks.

Security-sensitive contributions that touch datasets or research tooling will require additional review and approval.

✍️ Testing and CI

The project uses GitHub Actions for CI. The pipeline includes linting, static analysis, and unit tests.

πŸ“ Documentation

Full API documentation and developer guides are under docs/.

If you need downloadable model binaries or native runtimes, follow the explicit download URLs in docs/native-runtimes.md and verify checksums before installation.

πŸ” Contact and Reporting

For general issues, open an Issue on GitHub.

For security reports, follow the process described in SECURITY.md..

πŸ“‚ Notes and Warnings

Onetone combines powerful research tooling with runtime integrations. Misuse of native code, FFI, or malware datasets can cause severe security, privacy, and legal issues. Operate only in controlled, isolated environments and follow institutional and legal guidance.