I'm working with Angular 2 with php. Before I started PHP with Angular 2. I have done Angular 2 with node.js on server localhost:3000. Now with PHP, how I can configure my Angular 2 app with xampp server so my server code is running on localhost:8080. Please help me on this.
3 Answers
Here is my answer.
You can write Angular2 app just using Angular2 packages without using node or mamp or xampp and host that app. Ref
According to the above reference I created my app using angular 2 - cli after that I made a little change in my root directory index.html file which is:
<base href="/">
into
<base href="./">
and build my app using:
ng build --prod
copy dist folder and paste it in my xampp htdocs folder and access the site using:
localhost:8080/dist/
output
App works

- 1
- 1

- 5,636
- 16
- 44
- 81
-
@Ahmer Ali Ahsan this doesn't work for me with angular 5 – sk555 Sep 07 '18 at 09:43
-
@sk555 This answer is for angular 2. If you have facing issues in angular 5 related to my question kindly post it on Stack overflow. – Ahmer Ali Ahsan Sep 07 '18 at 11:51
-
@AhmerAliAhsan thanks is there any way to deploy angular ? – sk555 Sep 12 '18 at 14:16
-
Plunker & Stackblitz.com – Ahmer Ali Ahsan Sep 12 '18 at 14:46
-
1after refresh the page it's not working. for that what to do? – Soumya Gangamwar May 20 '19 at 08:46
-
Doesn't works for me as well – Moeez Oct 01 '21 at 06:49
You can host it on any server by first building the angular project using the command line:
ng build --base-href "/football/" --prod
This base href will mean that it expects the final server to be something like: localhost:8080/football/.
You want to get everything that is made in the dist folder and paste it into your server inside a folder called football.

- 1,647
- 14
- 9
I think that you are looking something similar to:
angular-cli server - how to proxy API requests to another server?
Just run your angular 2 application using the CLI, and add the proxy to use the services that are in xampp.

- 191
- 1
- 6