on
코드이그나이터 Rest Api 만들기
코드이그나이터 Rest Api 만들기
CI 다운로드
codeigniter.com/download
php ver : 5.6.8
CI ver : 3.1.11
API Root : /api/v1/CI Root
관련 코드 다운로드
github.com/mittarpal/CodeIgniter-Restful-API-Application
github.com/ctechhindi/CodeIgniter-API-Controller
CodeIgniter-Restful-API-Application-master.zip 0.69MB
API Documentation
/application/libraries/API_Controller.php
/application/helpers/api_helper.php
/application/config/api.php
Token Documentation
CI 에서 index.php 제거
/.htaccess
RewriteEngine On RewriteBase / RewriteCond $1 !^(index\.php|images|captcha|data|include|uploads|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /api/v1/index.php/$1 [L]
/api/v1/application/controllers/User_api.php
_apiConfig([ 'methods' => ['POST'], // Request Execute Only POST and GET Method ]); } }
혹시 아파치에서 권한 문제 발생시
Options FollowSymLinks AllowOverride All Order deny,allow Allow from all
* 추가사항
routers.php 사용시 parameter는 (:num) 또는 (:any) 만 사용
- 숫자형과 그 이외의 형
예) $route['v1/product/(:num)/(:any)/delete'] = 'v1/products/goods_del/$1/$2';
라우팅 참조 : www.ciboard.co.kr/user_guide/kr/general/routing.html
from http://devlink.tistory.com/427 by ccl(A) rewrite - 2021-03-31 12:00:33