PHP code example of rocboss / batio

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

    

rocboss / batio example snippets


route('GET /', ['api\HomeController', 'index']);

// Middlewares
'middlewares' => [
    'auth' => AuthMiddleware::class,
],

route('GET /', ['api\HomeController', 'user'])->auth();

// This method can be used to obtain JWT.
\Auth::getToken($uid);

if (app()->cache('data')->contains('foo')) {
    $unit = app()->cache('data')->fetch('foo');
} else {
    $bar = 'bar cache';
    app()->cache('data')->save('foo', $bar);
}

$logger = app()->log()->debug('debug log');

$userModel = new UserModel();
$userModel->name = 'Jack';
$userModel->email = '[email protected]';
$userModel->avatar = 'https://foo.com/xxxxxx.png';
$userModel->password = password_hash("mypassword", PASSWORD_DEFAULT);
$userModel->save();