#[RPC\Info]
Summary
Classname | Info | |
Namespace | Ufo\RpcObject\RPC | |
Target | class | |
Arguments: | ||
$alias | type | string |
optional | true | |
default | null | |
$concat | type | string |
optional | true | |
default | '.' |
Class Aliases
Sometimes it may be necessary to set an alternative name for an API method, for example, if you have a very long class name due to some standards or naming conventions in your project.
In such cases, you can add the attribute #[RPC\Info] to your class, specifying an alias for the class. This will instruct the RPC server to associate this alias with the class.
2
3
4
5
6
7
8
9
10
namespace App\Api\Procedures;
use Ufo\RpcObject\RPC;
#[RPC\Info(alias: 'users')]
class MySpecificApiUserServiceWithLongClassName implements IRpcService
{
public function getList(): void {}
}
In this case, the API method users.getList will be available.
Concatenation Symbol
The Info attribute also accepts a second argument concat, which specifies the character or characters that join the class name and method name when generating the ServiceMap for the RPC server.
The default value is "." (dot), but you can easily change it by specifying the symbol or characters you need.
2
3
4
5
6
7
8
9
10
namespace App\Api\Procedures;
use Ufo\RpcObject\RPC;
#[RPC\Info(alias: 'users', concat: '>')]
class MySpecificApiUserServiceWithLongClassName implements IRpcService
{
public function getList(): void {}
}
The example code above will result in the API method users>getList being available.
Caveats
In future
In the future, we plan to implement the ability to set aliases for each specific API method, not just classes.