Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Apigility获取资源名称和请求方法类型_Php_Zend Framework2_Laminas Api Tools_Zend Framework3 - Fatal编程技术网

Php Apigility获取资源名称和请求方法类型

Php Apigility获取资源名称和请求方法类型,php,zend-framework2,laminas-api-tools,zend-framework3,Php,Zend Framework2,Laminas Api Tools,Zend Framework3,如何在Apigility中获取资源名称? 我试过了 $route=$event->getRouteMatch() 但若资源名称包含的名称超过了名称,则将其拆分 例如,如果重新使用名称“employeeVerifySomething”,则返回“employee.verify.something”? 此外,我还需要获取请求类型以区分get-in“fetch&&fetch-all”的要点:“我还需要获取请求类型以区分get-in“fetch&&fetch-all” 对于fetchall,有条件的话,可

如何在Apigility中获取资源名称? 我试过了
$route=$event->getRouteMatch()
但若资源名称包含的名称超过了名称,则将其拆分

例如,如果重新使用名称“employeeVerifySomething”,则返回“employee.verify.something”? 此外,我还需要获取请求类型以区分get-in“fetch&&fetch-all”

的要点:“我还需要获取请求类型以区分get-in“fetch&&fetch-all”

对于fetchall,有条件的话,可以覆盖fetchall方法

$client = new \Zend\Http\Client($uri);
            $client->setMethod('GET');
            $client->setParameterGet(['id'=>1]);

       //Or
        $client->setParameterGet([]);
用于获取一个或获取方法

在url后添加id:

        $uri.'/'.$id;

您可以在
module.config.php
onBootstratp()方法中找到它们

public function onBootstrap(MvcEvent $e)
{
    $request = $e->getRequest();

    // Get the request method
    $method = $request->getMethod();

    // Get the path according to your format
    $path = $request->getUri()->getPath();
    $parts = explode('/', $path);
    if (!empty($parts)) {
        foreach ($parts as $part) {
            $words = preg_split("/((?<=[a-z])(?=[A-Z])|(?=[A-Z][a-z]))/", $part);
            if (!empty($words)) {
                $words = array_filter($words, function($value, $key){
                    return !empty($value);
                }, ARRAY_FILTER_USE_BOTH);
                $words = array_map('strtolower', $words);
            }
            $paths[] = join('.', $words);
        }
    }

    // Here is the formatted path
    $path = join("/", $paths);

    echo $method; // Outputs the requested method for example, GET
    echo $path; // Outputs employee.verify.something against employeeVerifySomething 
}
/hunkey.punkey/munkey.dunkey.chunkey