PHP code example of tivins / php-core

1. Go to this page and download the library: Download tivins/php-core 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/ */

    

tivins / php-core example snippets


use Tivins\PhpCore\DotEnv;

DotEnv::loadFile(__DIR__ . '/.env');
// ou, sans erreur si le fichier est absent :
DotEnv::tryLoadFile(__DIR__ . '/.env');

use Tivins\PhpCore\Request;

$response = Request::get('https://api.example.com/status')
    ->timeout(10)
    ->send();

if ($response->isSuccessful()) {
    $data = $response->decodeJson();
}

use Tivins\PhpCore\Api\AccessToken;
use Tivins\PhpCore\Api\Auth;

$token = AccessToken::issue($userId);
$userId = AccessToken::verify($token);

// ou, dans un endpoint :
$userId = Auth::

use Tivins\PhpCore\CliArgv;

$argv = CliArgv::fromGlobals();
$verbose = $argv->hasLongFlag('verbose');
$config = $argv->longFlagValue('config');