PHP 可使用变量调用:\App\$variable\etc

PHP call callable with a variable: \App\$variable\etc

我正在尝试拨打以下电话:

$group->get('/{xxx}', \App\Actions\Test\TestMe::class);

但是,我需要用字符串替换部分可调用对象

$foo = 'Test'
$group->get('/{xxx}', \App\Actions$foo\TestMe::class);

有办法吗?

目的是在代码处于sandbox/test环境

时获取不同的调用路径
"\App\Actions\$foo\TestMe" 

感谢 Viney 在评论中回答