0

We have a website written in php using the CakePHP framework which we want to move away from to angular 2

Is it possible to create an angular 2 page utilizing rest http calls and somehow plug that page seamlessly into our CakePHP website?

That way we can slowly move away from PHP

2
  • You will have to migrate all of your code from PHP to TypeScript Commented May 23, 2017 at 19:22
  • Please always mention your exact CakePHP version (last line in vendor/cakephp/cakephp/VERSION.txt or lib/Cake/VERSION.txt) Commented May 23, 2017 at 19:22

1 Answer 1

1

It is possible. However this won't be a matter of changing a thing or two. You controller methods will have to return json data like so:

public function index() {
        $recipes = $this->Recipe->find('all');
        $this->set(array(
            'recipes' => $recipes,
            '_serialize' => array('recipes')
        ));
    }

This will have to be done for every action that you will need to be accesed by Angular.

In addition, CakePHP offers some facilities to map certain request verbs to actions: https://book.cakephp.org/2.0/en/development/rest.html

Considering the amount of work it involves, I think that if you plan to move away from PHP, say to a node app, you are better off starting that app now instead of trying to adapt the CakePHP one. Unless you have a reason to.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.