As a rule, the separation of the administrator and the web application into two objects

I am creating a public web application for mobile devices that will have a significant admin-controlled end. Although this question is pretty general, I use CakePHP to build the application.

I am exploring it would be wise to separate administrative and public applications into two applications. Both applications will use the same database. The main reason I'm considering this is to improve security as well as portability of the interface.

I also thought about developing a RESTful CakePHP-based API that will be used by both the front and back end.

Would an API be the best way around this, or should each application just share the database only, or separate the applications, just creating more work in the end?

+1
source share
2 answers

I think it’s best to keep both admin functionality and REST API in your main CakePHP application. (You do not specify a version, but I assume that you are creating a new application using 2.0. It has some advantages below.)

, -, , , . Prefix Routing docs.

, , core.php:

Configure::write('Routing.prefixes', array('admin'));

, /admin/users/edit/ 5 admin_edit UsersController, 5 . /views/users/admin _edit.ctp.

"admin" routes.php:

Router::connect('/admin', array('controller' => 'pages', 'action' => 'index', 'admin' => true));

REST API, 2.0, , . REST.

route.php:

Router::mapResources('recipes');
Router::parseExtensions();

REST :

#HTTP format URL.format              Controller action invoked
GET          /recipes.format         RecipesController::index()
GET          /recipes/123.format     RecipesController::view(123)
POST         /recipes.format         RecipesController::add()
PUT          /recipes/123.format     RecipesController::edit(123)
DELETE       /recipes/123.format     RecipesController::delete(123)
POST         /recipes/123.format     RecipesController::edit(123)

, , , .

+4

, . , - "admin".

,

/
/controller/
/controller/action

..

/admin/
/admin/controller/
/admin/controller/action

..

+1

All Articles