-1

Can anyone please suggest that what is the best and preferred way to integrate AngularJs2 with Yii2 PHP Framework. I am unable to find clear steps.

I want Angular2 as Fronted and Yii2 as Backend.

Narendra Vyas
  • 717
  • 4
  • 9
  • 26
  • Hi, reference provided by you is of Angular-1 I am in need of Integration with Angular2 can you please help me providing some usefull links. – Narendra Vyas Mar 14 '17 at 06:08

1 Answers1

0

You can use the Angular2 for templating and everything on the frontend. And use its provided Http function to call for REST Api end point.

By doing this approach you are required to write everything again on your PHP framework.

In verbose explanation. Just request for data in PHP using http request then parse the returned JSON of the PHP framework.

So they talk only through API calls.

Reyan Tropia
  • 140
  • 1
  • 10
  • Yes correct they will communicate through REST thats fine but how can i use Angular2 for frontend ? I mean how can I integerate the two together ?? – Narendra Vyas Mar 10 '17 at 09:39
  • That's actually very dangerous as it wasn't intended and designed that way. Because all the Views are rendered by angular dynamically. It would be a very bad approach and would cause lots of problem in maintaining. But if you really want to go that way. I really have no idea. Since everything you need can be provided by angular. You just need to fetch the proper arrays of data from `PHP` to be used and binded by Angular . If I were you I wouldn't go that way. Since those two have very different principle in rendering views. – Reyan Tropia Mar 10 '17 at 09:43
  • Ok so if i go your way then can you please tell me what might be the clear steps to achieved that, as I have found some extensions of Reactjs to be integerated. Actually i am exploring how i can integerate Angular or React with any PHP framework or CMS ? – Narendra Vyas Mar 10 '17 at 09:54
  • Prepare all your template with Angular. Then use `services` to fetch data. Then bind that data to your template and use *ngFor to loop. So basically you just fetch a JSON object then put it on your template. Downside is you will handle also the routing but thats actually pretty easy comparing to you background. But then again this would be my prefered. Feel free to email me for question I would gladly help you starting up. reach me through zodiarkultima23@yahoo.com – Reyan Tropia Mar 10 '17 at 09:58