一、安装
方式1,使用 composer 安装 Luracast Restler
fetching resource verification-v2: http://localhost/userapi/resources/verification-v2.json?appKey=EerapQF16gc4
gao@gao-VirtualBox:/var/www/tctqAdvAPI$ sudo composer install
[sudo] password for gao:
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing luracast/explorer (v3.0.0)
Downloading: 100%
- Installing rodneyrehm/plist (dev-master 2ea0483)
Cloning 2ea0483806c989eb0518a767fa29a111bb29cb67
- Installing zendframework/zendamf (dev-master ac50749)
Cloning ac507493e7683acf5675bd0380c395c74d985c04
- Installing mustache/mustache (dev-master 64c28cc)
Cloning 64c28cc73e01d5edcef7de8cb2b16782615f648a
- Installing twig/twig (v1.13.0)
Downloading: 100%
- Installing bshaffer/oauth2-server-php (v1.0)
Downloading: 100%
- Installing symfony/finder (2.5.x-dev e527ebf)
Cloning e527ebf47ff912a45e148b7d0b107b80ec0b3cc2
- Installing symfony/yaml (2.8.x-dev 2396832)
Cloning 2396832f6f9ab2b8f62f00b5d3f2e722fc773d65
- Installing symfony/translation (2.8.x-dev a0735db)
Cloning a0735db452c5e592cb742333a32c6634a6d1ece1
- Installing symfony/event-dispatcher (2.8.x-dev 8766ceb)
Cloning 8766cebf28beac9a45b511d7dba053da9d35eb9f
- Installing symfony/dependency-injection (2.8.x-dev 90a7527)
Cloning 90a75274cb85bd6f9aaf4a017e5dee616ffe8a1d
- Installing symfony/filesystem (dev-master 80a0bc4)
Cloning 80a0bc4be4c2b037909e9e1a3abefd293a17a1a2
- Installing symfony/config (2.8.x-dev 291e3f1)
Cloning 291e3f1ce92fec71632eada0d492833b41531718
- Installing symfony/console (2.8.x-dev 7e857a2)
Cloning 7e857a2b52b5833ed27d78a6b1b846bd440ee8bd
- Installing behat/gherkin (2.3.x-dev c32e15d)
Cloning c32e15d92e1a2ce399a1a1c5be7afd965176e86c
- Installing behat/behat (v2.5.4)
Downloading: 100%
- Installing illuminate/support (4.2.x-dev 1317411)
Cloning 131741133aae79b085951b9382f42b088e479ef9
- Installing illuminate/filesystem (4.2.x-dev 3c4bab6)
Cloning 3c4bab6f4412db7d59f6b6f2c61104cdcbfb59aa
- Installing illuminate/container (4.2.x-dev 31433fb)
Cloning 31433fbfc3ea8d04fc691b3cbb2b027f8e126d1e
- Installing illuminate/events (4.2.x-dev 840a670)
Cloning 840a670de7d691fafb33505b8f8ee35490b4c90c
- Installing illuminate/view (4.2.x-dev 69d3cd8)
Cloning 69d3cd863dd9dd77f6fe0d9e742f1d79807b2653
- Installing guzzle/guzzle (v3.1.2)
Downloading: 100%
symfony/translation suggests installing psr/log (To use logging capability in translator)
symfony/event-dispatcher suggests installing symfony/http-kernel ()
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/console suggests installing symfony/process ()
symfony/console suggests installing psr/log (For using the console logger)
behat/behat suggests installing behat/symfony2-extension (for integration with Symfony2 web framework)
behat/behat suggests installing behat/yii-extension (for integration with Yii web framework)
behat/behat suggests installing behat/mink-extension (for integration with Mink testing framework)
Writing lock file
Generating autoload files
gao@gao-VirtualBox:/var/www/tctqAdvAPI$
-----------------------------------------------------------
gao@gao-VirtualBox:/var/www$ sudo composer create-project luracast/restler advApi
[sudo] password for gao:
Installing luracast/restler (3.0.0)
- Installing luracast/restler (3.0.0)
Downloading: 100%
Created project in advApi
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing luracast/explorer (v3.0.0)
Loading from cache
- Installing rodneyrehm/plist (dev-master 2ea0483)
Cloning 2ea0483806c989eb0518a767fa29a111bb29cb67
- Installing zendframework/zendamf (dev-master ac50749)
Cloning ac507493e7683acf5675bd0380c395c74d985c04
- Installing mustache/mustache (dev-master 64c28cc)
Cloning 64c28cc73e01d5edcef7de8cb2b16782615f648a
- Installing twig/twig (v1.13.0)
Loading from cache
- Installing bshaffer/oauth2-server-php (v1.0)
Loading from cache
- Installing symfony/finder (2.5.x-dev e527ebf)
Cloning e527ebf47ff912a45e148b7d0b107b80ec0b3cc2
- Installing symfony/yaml (2.8.x-dev 2396832)
Cloning 2396832f6f9ab2b8f62f00b5d3f2e722fc773d65
- Installing symfony/translation (2.8.x-dev a0735db)
Cloning a0735db452c5e592cb742333a32c6634a6d1ece1
- Installing symfony/event-dispatcher (2.8.x-dev 8766ceb)
Cloning 8766cebf28beac9a45b511d7dba053da9d35eb9f
- Installing symfony/dependency-injection (2.8.x-dev 90a7527)
Cloning 90a75274cb85bd6f9aaf4a017e5dee616ffe8a1d
- Installing symfony/filesystem (dev-master 80a0bc4)
Cloning 80a0bc4be4c2b037909e9e1a3abefd293a17a1a2
- Installing symfony/config (2.8.x-dev 291e3f1)
Cloning 291e3f1ce92fec71632eada0d492833b41531718
- Installing symfony/console (2.8.x-dev 7e857a2)
Cloning 7e857a2b52b5833ed27d78a6b1b846bd440ee8bd
- Installing behat/gherkin (2.3.x-dev c32e15d)
Cloning c32e15d92e1a2ce399a1a1c5be7afd965176e86c
- Installing behat/behat (v2.5.4)
Loading from cache
- Installing illuminate/support (4.2.x-dev 1317411)
Cloning 131741133aae79b085951b9382f42b088e479ef9
- Installing illuminate/filesystem (4.2.x-dev 3c4bab6)
Cloning 3c4bab6f4412db7d59f6b6f2c61104cdcbfb59aa
- Installing illuminate/container (4.2.x-dev 31433fb)
Cloning 31433fbfc3ea8d04fc691b3cbb2b027f8e126d1e
- Installing illuminate/events (4.2.x-dev 840a670)
Cloning 840a670de7d691fafb33505b8f8ee35490b4c90c
- Installing illuminate/view (4.2.x-dev 69d3cd8)
Cloning 69d3cd863dd9dd77f6fe0d9e742f1d79807b2653
- Installing guzzle/guzzle (v3.1.2)
Loading from cache
symfony/translation suggests installing psr/log (To use logging capability in translator)
symfony/event-dispatcher suggests installing symfony/http-kernel ()
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
symfony/console suggests installing symfony/process ()
symfony/console suggests installing psr/log (For using the console logger)
behat/behat suggests installing behat/symfony2-extension (for integration with Symfony2 web framework)
behat/behat suggests installing behat/yii-extension (for integration with Yii web framework)
behat/behat suggests installing behat/mink-extension (for integration with Mink testing framework)
Writing lock file
Generating autoload files
二、
(1),在 public 目录下创建 index.php, Api.php 文件(这里是 Say.php)
(2), 复制 explorer 文件夹放到 public 目录下
三、nginx 配置
server {
listen 80;
server_name api.test.com; # change it to match your server name
root /var/www/apiTest;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
if ( !-e $request_filename ) {
rewrite ^/public/(.*)$ /public/index.php?_REWRITE_COMMAND=$1;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# log
access_log /var/log/nginx/api_test.access.log;
error_log /var/log/nginx/api_test.error.log;
}
四、在浏览器中访问 http://api.advapi.com/public/explorer/index.html
http://api.test.com/public/explorer/index.html
五、如果遇到 404 : Not Found ../resources.json
则需要在 /var/www/apiTest/public 下创建 cache/ 并设置为可写权限
命令如下:
# cd /var/www/apiTest/public/
# sudo mkdir cache
# sudo chmod -R 777 cache/