PHP code example of xytoki / scf-flight

1. Go to this page and download the library: Download xytoki/scf-flight 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/ */

    

xytoki / scf-flight example snippets


$_POST
$_GET
$_FILES //不能太大
$_SERVER
$_COOKIE
Flight::request()->data
Flight::request()->body
Flight::response()->header("X-By","scFlight");
Flight::response()->status(404);
Flight::setcookie($key,$value,$options);    //php 7.3 setcookie方式
//Flight框架中的一切函数
//等等

header();           
setcookie();        //使用Flight::setcookie();代替
session_start();    //不支持,因为scf不保存session

if(isset($_ENV['TENCENTCLOUD_RUNENV'])){
    function main_handler($event, $context){
        return Flight::start($event, $context, dirname(__FILE__));
    }
}else{
    Flight::start();
}