svcphp / s
0.2.0
2021-01-26 10:21 UTC
Requires
- ext-curl: *
- ext-json: *
- ext-mcrypt: *
- ext-pdo: *
- ext-redis: *
This package is auto-updated.
Last update: 2024-05-29 04:48:04 UTC
README
controller demo
index.php
<?php require_once 'vendor/autoload.php'; include 'config.php'; $s = s::init(); $s->register('account.login'); $s->serve();
config.php
<?php $_CONFIG = [ 'SERVICE_APP' => 'usergateway', 'SERVICE_CALL_USER' => 'token123abc', ]; if (file_exists('user_config.php')) { /** @noinspection PhpIncludeInspection */ include 'user_config.php'; }
account.php
<?php class account { static function login($data) { $r = s::call('services.user.account.login', ['name' => $data['name'], 'password' => $data['password']]); return s::ok(['logined' => $r['data']['logined'] === true]); } }
user service demo
index.php
<?php require_once 'vendor/autoload.php'; include 'config.php'; $s = s::init(); $s->register('account.login', 1); $s->serve();
config.php
<?php $_CONFIG = [ 'SERVICE_APP' => 'userservice', 'SERVICE_ACCESSTOKENS' => ['token123abc' => 1, 'token456' => 2], ]; if (file_exists('user_config.php')) { /** @noinspection PhpIncludeInspection */ include 'user_config.php'; }
account.php
<?php class account { static function login($data) { $logined = $data['name'] === 'admin' && $data['password'] === 'admin'; return s::ok(['logined' => $logined]); } }