user698883
user698883

Reputation: 65

What is the best way to integrate a CakePHP app with a third party API framework?

On the same server I have a Restler 3.0 API server and also a CakePHP 2.3 application, I want to be able to use CakePHP controller functions from the Restler app. Of course I don't want CakePHP to do any rendering, just to deal with the data.

I considered just doing a https request to the CakePHP app from the Restler api, but this seemed pretty inefficient for the client of the Restler server. I also considered using RabbitMQ to do RPC between the apps but RPC in PHP seemed like too much complexity for something i'm trying to keep simple.

Ideally in Restler i might have something like this:

<?php
class Content {
    function post() {
        // CakePHP stuff:
        $data = array('title'=>'fake data');
        $this->Content->create();
        if ($this->Content->save($data)) {
            return 'ok';
        }
    }
}

I'm completely open to any good ideas on the best way to achieve this integration.

Upvotes: 0

Views: 951

Answers (1)

nsfyn55
nsfyn55

Reputation: 15363

Whether this is possible really depends on the nature of your environment.

Considerations:

  1. Does your controller use other cake framework components(Controllers, Models, components, etc.)? You might be hosed if this is the case because cake is convention oriented. Without the cake plumbing to interpret those conventions they are meaningless.

If you just need to repurpose some non-cake specific PHP logic you could always refactor it into its own php class or even just a .php file with some functions in it and share them between your Restler App and your Cake Application.

Upvotes: 0

Related Questions