1

Running an angular app in php framework

I have a angular app running standalone(node server) https://site_url:8018/ which I want to use in my php framework. https://site_url/editor/id/1

I want to be able to pass the id plus other values from php framework e.g. csrf token etc.. to this angualr app without making any xhr call

The angular app uses endpoints which will be in my php site as well.

What would be the best solution to deal with this situation and how?

also the main site is running on https://site_url/ and I would like to use this address for angular app https://site_url/editor/id/1, how I can achieve this?

Arian
  • 465
  • 1
  • 7
  • 18
  • 1
    You make APIs in PHP and make your angular app call those APIs for JSON data. For authentication, you could use [JSON web tokens](https://jwt.io/introduction/). – nice_dev Oct 03 '19 at 07:16
  • thanks @vivek_23, sorry but what I wanted to know first is how I can run my angular app on my php site. My site url is https://site_url/ and I want my angular app(https://site_url:8018/) to to run here – Arian Oct 03 '19 at 09:21
  • As far as I know, we host angular app separately. I have never tried it inside a PHP framework. – nice_dev Oct 03 '19 at 09:50
  • See [Angular deployment](https://angular.io/guide/deployment). – nice_dev Oct 03 '19 at 09:52
  • I think I have 2 options, **First** to use ng build --prod . - then copy the dist folder in assets folder of my php site and then in view file of framework copy index.html content and change base href value accordingly. **Second** as you mentioned earlier, run & host the angular app separately and us API's for JSON data. As I have never done this, I am just curious what is the best and preferred way to do in this situation when you want to use any third party angular component in your existing php site? – Arian Oct 03 '19 at 19:52
  • 1
    IMO, deploying it separately is the best way. This thread seems useful https://stackoverflow.com/questions/35539622/how-do-you-deploy-angular-apps – nice_dev Oct 04 '19 at 08:01

1 Answers1

-1

You could use cookies or sessions that has access by both angular and php.