1. Go to this page and download the library: Download daycry/restserver 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/ */
namespace App\Controllers;
class Center extends \Daycry\RestServer\RestServer
{
public function index()
{
return $this->respond( $this->content );
}
}
namespace App\Controllers;
class Center extends \Daycry\RestServer\RestServer
{
public function __construct()
{
$this->_restConfig = config('RestServer');
$this->_restConfig->restAjaxOnly = true;
}
public function index()
{
return $this->respond( $this->content );
}
}
public $ame' => '
namespace App\Controllers;
class Center extends \Daycry\RestServer\RestServer
{
public function index()
{
$this->validation( '
namespace App\Controllers;
class Center extends \Daycry\RestServer\RestServer
{
public function index()
{
$this->validation( '
public $restUsersTable = 'restserver_user'; //user table name
public $userModelClass = \Daycry\RestServer\Models\UserModel::class; //user model Class
public $userKeyColumn = 'key_id'; // column that associates the key
namespace App\Exceptions;
use CodeIgniter\Exceptions\FrameworkException;
class SecretException extends FrameworkException
{
protected $code = 401;
public static $authorized = true;
public static function forInvalidPassphrase()
{
self::$authorized = false;
return new self(lang('Secret.invalidPassphrase'));
}
public static function forInvalidToken()
{
self::$authorized = false;
return new self(lang('Secret.invalidToken'));
}
public static function forExpiredToken()
{
self::$authorized = false;
return new self(lang('Secret.tokenExpired'));
}
public static function forTokenReaded()
{
self::$authorized = false;
return new self(lang('Secret.readed'));
}
}
php spark restserver:discover
/**
*--------------------------------------------------------------------------
* Cronjob
*--------------------------------------------------------------------------
*
* Set to TRUE to enable Cronjob for fill the table petitions with your API classes
* $restNamespaceScope \Namespace\Class or \Namespace\Folder\Class or \Namespace example: \App\Controllers
*
* This feature use Daycry\CronJob vendor
* for more information: https://github.com/daycry/cronjob
*
*/
public string $restApiTable = 'ws_apis';
public string $restNamespaceTable = 'ws_namespaces';
public array $restNamespaceScope = ['\App\Controllers', '\Api\Controllers'];
/*
|--------------------------------------------------------------------------
| Cronjobs
|--------------------------------------------------------------------------
|
| Register any tasks within this method for the application.
| Called by the TaskRunner.
|
| @param Scheduler $schedule
*/
public function init(Scheduler $schedule)
{
$schedule->command('restserver:discover')->named('discoverRestserver')->daily();
or
$schedule->command('restserver:discover')->named('discoverRestserver')->daily('11:30 am');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.