4

I am a PHP developer and also I have developed Angular 6 apps using Node.js backend. But, currently I am working on a project which should run an Angular 6 app with a PHP 7 back-end. The reason is that, the API was written in PHP. I wish to develop my Angular app in WAMP server default directory.

wamp64/www/my_project

So my questions are,

  1. Will the Angular 6 app run? Because it needs another server and normally it is http://localhost:4200/.
  2. Would there any server (localhost) collisions?
  3. If it is, what should I do?

  4. Also, can I run <?php session_start();?> on the beginning of index.html(or .php) file?

PCBoy9999
  • 41
  • 1
  • 3
  • 1
    You can run Angular on WAMP. You need to run session_start in a .php file. It needs to process the actual php code. – unixmiah Aug 08 '18 at 13:59
  • @unixmiah Thank you for advice. But could you please tell me or give me any link, how should I implement session_star on an Angular 6 app? As I know, there is only one index.html available, right? – PCBoy9999 Aug 08 '18 at 14:05
  • https://stackoverflow.com/questions/26720047/running-php-within-angular – unixmiah Aug 08 '18 at 15:10
  • make sure to use .php file extension – unixmiah Aug 08 '18 at 15:11

1 Answers1

3

You can write Angular2 app just using Angular2 packages without using node or mamp or xampp and host that app.

If you have written any thing in Angular2 and node.js combination then you can host it on free services like Heroku for testing purpose.

and build 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

Rizwan
  • 3,741
  • 2
  • 25
  • 22
  • Excellent..!! It means that, I should finish my client side work first. Thank you..! Also, can I then use php session_start function in that index.html file? (of course, I should rename it..) – PCBoy9999 Aug 08 '18 at 14:12
  • I was able to run the app, but not the backend. Do you run the PHP backend on the same server ? – lads Oct 04 '18 at 06:53
  • I am unable to run the app even after following the above mentioned steps. It shows black browser screen and css 404 errors in the log. – Sarim Javaid Khan Jan 25 '19 at 13:12