PHP code example of ivampiresp / laravel-rpc-server
1. Go to this page and download the library: Download ivampiresp/laravel-rpc-server 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/ */
ivampiresp / laravel-rpc-server example snippets
use App\Http\Procedures\YourProcedure;
use Illuminate\Support\Facades\Route;
// ...
->withRouting(
health: '/up',
then: function () {
Route::rpc('/api', [YourProcedure::class]);
}
)
namespace App\Http\Procedures;
use Sajya\Server\Procedure;
class YourProcedure extends Procedure
{
/**
* 方法名称
*
* @var string
*/
public static string $name = 'yourProcedure';
/**
* 示例方法
*
* @param string $message
* @return string
*/
public function hello(string $message): string
{
return "Hello, {$message}!";
}
}