Reputation: 179
Actually I want integrate Angular functionality inside PHP Application.
PHP Application running currently on live ( having separate database and API calls written in Java)
Angular Application which I am developing currently (ng7) have it's own database and API calls written in Java.
Is it possible to run both apps under PHP site ( domain will not change)
If yes then how can I integrate Angular app inside PHP site for e.g. PHP site will have a menu i.e. when user clicks on that menu then page loaded will be an Angular and all functionality inside that menu will be of Angular calling it's own Java API's
Do we need to handle session in this case if two apps are running separately, and how to pass control from PHP site to Angular and vice versa
Upvotes: 1
Views: 267
Reputation: 3502
Yes you can run both of the application on the same domain but you will require any folder pattern to keep the Angular App bundle.
E.g. you have a domain http://example.com then you can write an .htaccess rule to forward the conditional request to Angular and others to PHP.
Then for that PHP URL, you need to provide the href='' link in the Angular rather than the routerlink otherwise Angular will find that module in the Angular route.
You also need to take care about the baseUrl
of your application.
Sample .htaccess
rule looks like
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|flv|mpeg|mpg|mp4)$
RewriteRule ^.*$ index.html [NC,L]
Keep it in same directory where you are putting your Angular code.
Upvotes: 1