我試圖在我的CakePHP項目中使用Swagger-PHP,我遇到了一些問題。有人設置了嗎?你有什麼建議嗎?我已經通過作曲家成功安裝了swagger-php,並將其加載到我的控制器中(參見下文)。我試圖通過網絡視圖呈現規範,我不太確定爲什麼註冊表沒有被填充或甚至需要。Swagger-PHP和CakePHP
以下是ApiController.php
結果object(Swagger\Swagger) {
resourceList => array()
registry => array()
models => array()
[protected] fileList => array(
(int) 0 => '~/Sites/com/sitename-api/app/Model/[ModelName].php',
... All of my models
)
[protected] path => '~/Sites/com/sitename-api/app/Model'
[protected] excludePath => '~/Sites/com/sitename-api/app/Model/Behavior'
[protected] cache => object(Doctrine\Common\Cache\ArrayCache) {
[private] data => array(
'DoctrineNamespaceCacheKey[]' => (int) 1,
'[][1]' => 'a:4:{s:8:"registry";a:0:{}s:6:"models";a:0:{}s:4:"path";N;s:11:"excludePath";N;}',
'[cd9db43f54f6017ba1a20037c1577eb4d2017868][1]' => 'a:4:{s:8:"registry";a:0:{}s:6:"models";a:0:{}s:4:"path";s:56:"~/Sites/com/sitename-api/app/Model";s:11:"excludePath";s:65:"~/Sites/com/sitename-api/app/Model/Behavior";}'
)
}
[protected] cacheKey => 'cd9db43f54f6017ba1a20037c1577eb4d2017868'
}
所以
use Swagger\Annotations as SWG;
use Swagger\Swagger;
public function swagger(){
$path = APP . 'Model'; //Path to the app directory
$swagger = Swagger::discover($path,APP . 'Model/Behavior');
debug($swagger);
//$swagger->jsonEncode($swagger->registry['/api']);
$swagResults = $swagger->registry;
debug($swagResults);
$this->set(array(
'results' => $swagResults,
'_serialize' => 'results'
));
}
內,基本上$ swagResults是空的,我猜這應該不是吧?