PHP code example of dccheng / kernel

1. Go to this page and download the library: Download dccheng/kernel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dccheng / kernel example snippets


Kernel::init();

Kernel::init([
     "you class alias"=>YourClass::class
     ...
]);

try {
    $token = Kernel::token()->create($userInfo);
    
    //设定请求参数,可缺省默认为Token
    Kernel::token()->param = "Token";
    
    //初始化token生存时间,可缺省默认为7200
    Kernel::token()->exp = 3600 * 24 * 30;
    
    //如果为ture校验请求的header HTTP_AUTHORIZATION属性
    //如果为false则校验$_GET或者$_POST的Token属性
    //可缺省默认为true
    Kernel::token()->isValidateHeader = false;
    
    if(Kernel::token()->validate()){
        echo "校验通过";
    }else{
        echo "校验不通过";
    }
} catch (Exception $exception) {
    echo $exception->getMessage();
}

try {
    Kernel::command()->addCommand([
        DBCommand::backup($user,$password,$dbname,$filename),
        VideoCommand::screenCaptureCommand("E:/download/3.mkv","image","E:/download/",150),
        "rm -Rf filename",
        "..."
    ])->execute(false);
} catch (Exception $exception) {
    echo $exception->getMessage();
}