NMW
NMW

Reputation: 33

Cakephp 2.4 Restful json web service and admin web site

Im very new to php and i found cakephp to build my restful json web service with its admin site. I have go through the cake book and resources and done the blog tutorial and found jsonViews are very helpful. So my requirement is i need to build a JSON API and and its Admin site. Then Admin can login to its HTML site and update the content to the database. Finally updated content in the DB can access via JSON API endpoints.

So my question is how to build both admin site and API in same cakephp project.? In same controller how to handle html and json requests.? Can anyone guide me or provide tutorials/resources etc.

Thanks in advance.

Upvotes: 1

Views: 1600

Answers (1)

Mindaugas Norvilas
Mindaugas Norvilas

Reputation: 532

I would suggest you to build a plugin for API calls. Then create route rules for example:

Router::connect('/api/projects', 
    array('plugin' => 'api', 'controller' => 'projects', 'action' => 'index'));

So, basically you can handle all API requests in separate plugin. This way it will be easier to maintain your project.

Upvotes: 1

Related Questions