Rui K. answered 05/05/23
Tutor
New to Wyzant
Seasoned Online Tutor & JavaScript Expert
- Should you build your back-end only as RESTful app and use JSON response/request with Angular and PHP? Yes, building a RESTful API with JSON response/request is a good approach for building the back-end of an Angular- PHP application. This approach allows for separation of concerns between the front-end (Angular) and back-end (PHP), making it easier to maintain and scale the application in the future.
- What about the view in PHP app? Should you use them with ng-init? It's generally not recommended to mix PHP views with AngularJS, as this can lead to issues with maintaining separation of concerns and can make it harder to optimize your application for performance. Instead, you can use Angular's built-in directives and templates to handle view rendering.
- Routing, server-side or client-side? In an Angular-PHP application, routing can be done either server-side or client-side. Server-side routing involves defining routes and handling HTTP requests in PHP, while client-side routing involves using Angular's built-in routing module to handle client-side navigation. Both approaches have their pros and cons, so it depends on your specific use case and requirements.
- What about caching? Caching can help improve the performance of your Angular-PHP application by reducing the number of HTTP requests made to the server. You can implement caching at both the client-side (using browser caching, for example) and server-side (using a caching layer such as Redis or Memcached).
- Where should you put the logic about data that user will input? In an MVC architecture, the logic for handling user input would typically be placed in the Controller layer. In practice, this could involve validating user input, processing the data, and updating the model accordingly.