1. Go to this page and download the library: Download sky337/secure-api 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/ */
sky337 / secure-api example snippets
use Sky337\SecureAPI\Traits\HasRoles;
class User extends Authenticatable
{
use HasRoles;
}
$user->assignRole('admin');
if ($user->hasRole('admin')) {
// Logic for admin
}
if ($user->hasAnyRole(['admin', 'editor'])) {
// Logic for admin or editor
}
use Sky337\SecureAPI\Classes\ApiResponse;
return ApiResponse::success($data, 'User fetched successfully');
return ApiResponse::error('Something went wrong', 400);
return ApiResponse::validationError($validator->errors());