{"id":315,"date":"2020-08-20T15:23:23","date_gmt":"2020-08-20T13:23:23","guid":{"rendered":"http:\/\/www.myblog.nguenkam.com\/?p=315"},"modified":"2020-11-10T14:02:42","modified_gmt":"2020-11-10T13:02:42","slug":"angular-app-with-php-backend","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2020\/08\/20\/angular-app-with-php-backend\/","title":{"rendered":"Angular app with PHP backend"},"content":{"rendered":"\n<h3>Learn to code Angular app with PHP backend<\/h3>\n\n\n\n<p>In the following tutorials, you&#8217;ll learn how build a whole application , with Angular (Frontend )  &amp; PHP ( Backend) .  We will create an easy CRUD application ,to add, update, and delete items.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"960\" height=\"714\" src=\"https:\/\/www.myblog.nguenkam.com\/wp-content\/uploads\/2020\/08\/angular_php_application_demo.gif\" alt=\"\" class=\"wp-image-316\"\/><\/figure>\n\n\n\n<h4><a>#<\/a>&nbsp;1. Install Angular<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>> npm install -g @angular\/cli\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>> ng new cars<\/code><\/pre>\n\n\n\n<p>The first command installs the&nbsp;<strong>Angular\/CLI<\/strong>&nbsp;working environment, and the second generates a new Angular app with the name of cars. (ps: You must have Nodejs\/ npm installed on your computer).<\/p>\n\n\n\n<p>Once the installation has finished, cd into the app&#8217;s folder and then serve the app:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> cd cars\/\n> ng serve --o<\/code><\/pre>\n\n\n\n<p>It may take a while until the installation finishes and the app launches, but if everything is working according to plan you need to see Angular&#8217;s default homepage.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img src=\"https:\/\/www.myblog.nguenkam.com\/wp-content\/uploads\/2020\/08\/first_screen_angular_app.png\" alt=\"ng-app\" class=\"wp-image-317\"\/><\/figure>\n\n\n\n<p>To give the app a nice look, include the link to the Bootstrap&#8217;s (CSS framework) stylesheet in the&nbsp;<strong>index.html<\/strong>&nbsp;header.<\/p>\n\n\n\n<p><strong><u>src\/index.html<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!doctype html>\n&lt;html lang=\"en\">\n&lt;head>\n  &lt;meta charset=\"utf-8\">\n  &lt;title>Cars&lt;\/title>\n  &lt;base href=\"\/\">\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.1.3\/css\/bootstrap.min.css\">\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  &lt;link rel=\"icon\" type=\"image\/x-icon\" href=\"favicon.ico\">\n&lt;\/head>\n&lt;body>\n  &lt;app-root>&lt;\/app-root>\n&lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p>Here I use a CDN as the source of the stylesheet.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;2. Add the HttpClientModule to the project<\/h4>\n\n\n\n<p><strong>Angular<\/strong>&#8216;s preferred way to communicate with the server side is through the&nbsp;<strong>HttpClientModule<\/strong>&nbsp;module.<\/p>\n\n\n\n<p>To be able to use the&nbsp;<strong>HttpClientModule<\/strong>, you need to import it into the root module of the application:<\/p>\n\n\n\n<p><strong><u>src\/app\/app.module.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { BrowserModule } from '@angular\/platform-browser';\nimport { NgModule } from '@angular\/core';\nimport { HttpClientModule } from '@angular\/common\/http';\n\nimport { AppComponent } from '.\/app.component';\n\n@NgModule({\n  declarations: &#91;\n    AppComponent\n  ],\n  imports: &#91;\n    BrowserModule,\n    HttpClientModule\n  ],\n  providers: &#91;],\n  bootstrap: &#91;AppComponent]\n})\nexport class AppModule { }<\/code><\/pre>\n\n\n\n<p>It is not enough to import the module you should also add it&#8217;s symbol to the&nbsp;imports&nbsp;array.<\/p>\n\n\n\n<p>After importing, you will be able to use the module in the various parts of the application, such as in the components and services.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;3. Add the Car class<\/h4>\n\n\n\n<p>A car is not just a thing, and since you work with TypeScript, you better define the type. You will do this with the&nbsp;Car&nbsp;class, which you need to add to the app. For this, manually create a&nbsp;<strong>car.ts<\/strong>&nbsp;file in the&nbsp;<strong>src\/app<\/strong>&nbsp;folder, and put the following code inside:<\/p>\n\n\n\n<p><strong><u>src\/app\/car.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export class Car {\n  constructor(\n    model: string,\n    price: number,\n    id?:   number) {}\n}<\/code><\/pre>\n\n\n\n<p>Besides the price and model name, the class contains an id which is an optional field, hence the question mark.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;4. Place the method to communicate with the server in a service<\/h4>\n\n\n\n<p>While you can call AJAX directly from the components, this is not a best practice because you may want to use the same methods in different parts of the application. Therefore, it is better to put these methods in a dedicated service. In our case, it will be a service with the name of&nbsp;car.service.<\/p>\n\n\n\n<p>To generate the service run the following command in the CLI:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> ng generate service app\/car --flat --spec=false<\/code><\/pre>\n\n\n\n<p>The command includes two flags:<\/p>\n\n\n\n<p><strong>&#8211;flat<\/strong>&nbsp;because you want the service to contain only files instead of being locked in a folder.<\/p>\n\n\n\n<p><strong>&#8211;spec=false<\/strong>&nbsp;to prevent the generation of a unit test file.<\/p>\n\n\n\n<p>Inside the generated file you will see the following code:<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Injectable } from '@angular\/core';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class CarService {\n}<\/code><\/pre>\n\n\n\n<p>The&nbsp;Injectable&nbsp;decorator allows the service to participate in the&nbsp;<strong>dependency injection system<\/strong>. Which means that on the one hand, it can have dependencies (i.e., the HttpClientModule module), and on the other hand, it can be injected, for example into the components.<\/p>\n\n\n\n<p>But what is a dependency? A&nbsp;<strong>dependency<\/strong>&nbsp;is when one class depends on another for its function.<\/p>\n\n\n\n<p class=\"has-text-align-center has-vivid-cyan-blue-color has-text-color\"><em>A&nbsp;<\/em><strong>dependency<\/strong><em>&nbsp;is when one class depends on another for its function.<\/em><\/p>\n\n\n\n<p>Angular&#8217;s way of managing the app dependencies is through the&nbsp;<strong>Dependency Injection<\/strong>&nbsp;system or&nbsp;<strong>DI<\/strong>, whose job it is to create for us the classes that we need in the right place at the right time.<\/p>\n\n\n\n<p>A common practice of creating objects in object-oriented programming is by using the&nbsp;new&nbsp;keyword. For example, if you are interested in an&nbsp;HttpClientModule&nbsp;object, then you might be tempted to write the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private http = new HttpClient<\/code><\/pre>\n\n\n\n<p>But this is not the Angular way because when developing with Angular it is strongly advised to use the Dependency Injection system to manage the objects that the class needs.<\/p>\n\n\n\n<p class=\"has-text-align-center has-vivid-cyan-blue-color has-text-color\"><em>when developing with Angular it is strongly advised to use the Dependency Injection system to manage the objects that the class needs.<\/em><\/p>\n\n\n\n<p>For the&nbsp;CarService&nbsp;to function, it needs to inject the&nbsp;HttpClientModule&nbsp;dependency and import the various classes needed to manage the communication with the server.<\/p>\n\n\n\n<p>Replace the code inside the service file with this:<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Injectable } from '@angular\/core';\nimport { HttpClient, HttpErrorResponse, HttpParams } from '@angular\/common\/http';\n\nimport { Observable, throwError } from 'rxjs';\nimport { map, catchError } from 'rxjs\/operators';\n\nimport { Car } from '.\/car';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class CarService {\n  constructor(private http: HttpClient) { }\n}<\/code><\/pre>\n\n\n\n<p>The dependency injection is done in the constructor, by defining the private&nbsp;HTTP&nbsp;variable as belonging to the&nbsp;HttpClient&nbsp;type, which instructs Angular to handle the creation of the HttpClient object for us by using the DI.<\/p>\n\n\n\n<p>Importing from the&nbsp;<a href=\"https:\/\/phpenthusiast.com\/blog\/what-is-observable-in-angular\">RxJS<\/a>&nbsp;library allows us to work with the&nbsp;<strong>Observable<\/strong>&nbsp;that Angular wraps around the data that is coming from the server. Using an&nbsp;<strong>Observable<\/strong>&nbsp;instead of a standard callback to handle asynchronous code offers several advantages, including multiple operators that facilitate data handling, as well as the ability to listen to data that the server emits repeatedly over time.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;5. Displaying the list of cars coming from the server<\/h4>\n\n\n\n<p>To get the list of cars coming from the server, write the following code inside the class:<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>baseUrl = 'http:\/\/localhost\/api';\ncars: Car&#91;];\n                \nconstructor(private http: HttpClient) { }\n                \ngetAll(): Observable&lt;Car&#91;]> {\n  return this.http.get(`${this.baseUrl}\/list`).pipe(\n    map((res) => {\n      this.cars = res&#91;'data'];\n      return this.cars;\n  });\n}<\/code><\/pre>\n\n\n\n<p>The&nbsp;getAll()&nbsp;method returns the list of cars wrapped in an Observable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getAll(): Observable&lt;Car&#91;]> {\n}<\/code><\/pre>\n\n\n\n<p>We use the HttpClient&nbsp;get()&nbsp;method to fetch the data from the server side:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getAll(): Observable&lt;Car&#91;]> {\n  return this.http.get(`${this.baseUrl}\/list`)\n}<\/code><\/pre>\n\n\n\n<p>The data returned from the server is the list of cars wrapped inside an external array (a common case when consuming APIs).<\/p>\n\n\n\n<p>This is how the data returned from the server looks like (we&#8217;ll get to writing the code for the server side in a short time):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  data: \n  &#91;\n    {\n      id: \"1\",\n      model: \"subaru\",\n      price: \"120000\"\n    },\n    {\n      id: \"2\",\n      model: \"mazda\",\n      price: \"160000\"\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p>Since you are interested only in the list of cars in the innermost array you need to extract the list. For this job, you will use the RxJS&nbsp;pipe()&nbsp;operator that you need to chain to the&nbsp;get()&nbsp;method. Inside the pipe operator, you will map the array of cars that come from the server side to the service&#8217;s local&nbsp;cars&nbsp;variable.<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getAll(): Observable&lt;Car&#91;]> {\n  return this.http.get(`${this.baseUrl}\/list`).pipe(\n    map((res) => {\n      this.cars = res&#91;'data'];\n      return this.cars;\n    });\n}<\/code><\/pre>\n\n\n\n<p>So far, you&#8217;ve seen what to do when the data is OK, but what happens if the server side returns an error code. For example, 404, not found, or 500 in case of server error? In these cases, the&nbsp;getAll()&nbsp;method needs to call another one of Angular&#8217;s methods,&nbsp;catchError():<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getAll(): Observable&lt;Car&#91;]> {\n  return this.http.get(`${this.baseUrl}\/list`).pipe(\n    map((res) => {\n      this.cars = res&#91;'data'];\n      return this.cars;\n  }),\n  catchError(this.handleError));\n}<\/code><\/pre>\n\n\n\n<p>catchError()&nbsp;has the parameter of the method that needs to handle the errors,&nbsp;handleError:<\/p>\n\n\n\n<p><strong><u>src\/app\/car.service.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private handleError(error: HttpErrorResponse) {\n  console.log(error);\n \n  \/\/ return an observable with a user friendly message\n  return throwError('Error! something went wrong.');\n}<\/code><\/pre>\n\n\n\n<p>The error handling includes the throwing of a general error message and a&nbsp;console.log()&nbsp;for debugging purposes.<\/p>\n\n\n\n<p>Note that in order for the observable to work, it is not enough that you have the&nbsp;get()&nbsp;method in the service, you also need to actively send the data to the component.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;6. The code in the component which subscribes to the data<\/h4>\n\n\n\n<p>To be able to display the data to the client, you need a method inside the component which&nbsp;subscribes&nbsp;to the data that the service fetches from the server. Write the following code inside the component file:<\/p>\n\n\n\n<p><strong><u>src\/app\/app.component.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Component, OnInit } from '@angular\/core';\n\nimport { Car } from '.\/car';\nimport { CarService } from '.\/car.service';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: '.\/app.component.html',\n  styleUrls: &#91;'.\/app.component.css']\n})\nexport class AppComponent implements OnInit {\n  cars: Car&#91;];\n  error = '';\n  success = '';\n        \n  constructor(private carService: CarService) {\n  }\n        \n  ngOnInit() {\n    this.getCars();\n  }\n        \n  getCars(): void {\n  }\n}<\/code><\/pre>\n\n\n\n<p>The variable&nbsp;cars&nbsp;inside the component stores the array of cars retrieved from the server.<\/p>\n\n\n\n<p>In the constructor, you inject the&nbsp;carService&nbsp;dependency so that the service will be available to all the methods of the controller as soon as Angular creates an object out of the controller.<\/p>\n\n\n\n<p>Inside the&nbsp;ngOnInit()&nbsp;lifecycle hook, you call the&nbsp;getCars()&nbsp;method just after the creation of the controller by Angular.<\/p>\n\n\n\n<p>ngOnInit&nbsp;is a special lifecycle hook provided by Angular that runs immediately after the constructor finishes injecting the dependencies, so it is a good place to get the array of cars into the controller.<\/p>\n\n\n\n<p>Let&#8217;s add the&nbsp;getCars()&nbsp;method that subscribers to the data that comes from the service:<\/p>\n\n\n\n<p><strong><u>src\/app\/app.component.ts<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getCars(): void {\n  this.carService.getAll().subscribe(\n    (res: Car&#91;]) => {\n      this.cars = res;\n    },\n    (err) => {\n      this.error = err;\n    }\n  );\n}<\/code><\/pre>\n\n\n\n<ul><li>The first callback is for handling the successful retrieval of the list of cars.<\/li><li>The second callback handles errors.<\/li><\/ul>\n\n\n\n<p>When we subscribe to observable we expect one of three results:<\/p>\n\n\n\n<ul><li>Getting the requested data from the server side (the array of cars).<\/li><li>An error on the server side.<\/li><li>An indication that the stream of data has finished.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>In our case, only the first two results are relevant because the action is not expected to end since the list can be updated at any time with the items that our users add to the list .<\/p>\n\n\n\n<p>Now all you have left is to show the HTML with the list of cars, and with the messages of success or error.<\/p>\n\n\n\n<p><strong><u>src\/app\/app.component.html<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div *ngIf=\"error\">{{error}}&lt;\/div>\n&lt;div *ngIf=\"success\">{{success}}&lt;\/div>\n    \n&lt;div id=\"theList\">\n  &lt;h2>The list&lt;\/h2>\n  &lt;ul>\n    &lt;li *ngFor=\"let item of cars\">{{item.model}} | {{item.price}} &lt;\/li>\n  &lt;\/ul>\n&lt;\/div><\/code><\/pre>\n\n\n\n<p>The list will be printed to the screen within the&nbsp;ngFor&nbsp;loop from the array of cars, once we set up the PHP backend server.<\/p>\n\n\n\n<h4><a>#<\/a>&nbsp;7. The server side of the project<\/h4>\n\n\n\n<p>I wrote server-side as a simple&nbsp;<strong>PHP<\/strong>&nbsp;script with a&nbsp;<strong>MySQL<\/strong>&nbsp;database. The same principles can be applied to any paradigm, framework or language.<\/p>\n\n\n\n<p>For this tutorial I used XAMPP environment which runs on my computer.<\/p>\n\n\n\n<p>The following is the MySQL code for generating the database table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE IF NOT EXISTS `cars` (\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n  `model` varchar(255) NOT NULL DEFAULT '',\n  `price` int (10) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=utf8;<\/code><\/pre>\n\n\n\n<p>Put the PHP scripts in a folder with the name of&nbsp;<strong>api\/<\/strong>&nbsp;on the server.<\/p>\n\n\n\n<p>The&nbsp;<strong>.htaccess<\/strong>&nbsp;file is the configuration file of the Apache server, in which you specify two rules:<\/p>\n\n\n\n<ol><li>A rule to remove the PHP extension from the file names.<\/li><li>Headers to allow the Angular part of the application to transfer data and perform operations on the PHP server.<\/li><\/ol>\n\n\n\n<p><strong><u>api\/.htaccess<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Remove the php extension from the filename\nRewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^(&#91;^\\.]+)$ $1.php &#91;NC,L]\n\n# Set the headers for the restful api\nHeader always set Access-Control-Allow-Origin http:\/\/localhost:4200\nHeader always set Access-Control-Max-Age \"1000\"\nHeader always set Access-Control-Allow-Headers \"X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding\"\nHeader always set Access-Control-Allow-Methods \"POST, GET, OPTIONS, DELETE, PUT\"\n<\/code><\/pre>\n\n\n\n<p>The header part of the&nbsp;<strong>.htacess<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Header always set Access-Control-Allow-Origin \"http:\/\/localhost:4200\"<\/code><\/pre>\n\n\n\n<p>Instructs the server to give the Angular app the necessary privileges even though the web address is different.<\/p>\n\n\n\n<p>The rest of the headers permit the exchange of data between the Angular side and the server side using the&nbsp;<strong>HTTP protocol methods<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>GET<\/strong><\/td><td>To retrieve the data about a single resource* or a list of resources<\/td><\/tr><tr><td><strong>POST<\/strong><\/td><td>To store a new resource<\/td><\/tr><tr><td><strong>PUT<\/strong><\/td><td>To update the data that is already found on the server<\/td><\/tr><tr><td><strong>DELETE<\/strong><\/td><td>To destroy a resource<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>* A resource is roughly equivalent to a single row in the database. In our app, every car is a resource.<\/p>\n\n\n\n<p>The application conforms to the&nbsp;<strong>REST API<\/strong>&nbsp;architecture.<\/p>\n\n\n\n<p>The&nbsp;<strong>connect.php<\/strong>&nbsp;script creates the connection with the database:<\/p>\n\n\n\n<p><strong><u>api\/connect.php<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n\/\/ db credentials\ndefine('DB_HOST', 'localhost');\ndefine('DB_USER', 'root');\ndefine('DB_PASS', '');\ndefine('DB_NAME', 'angular_db');\n\n\/\/ Connect with the database.\nfunction connect()\n{\n  $connect = mysqli_connect(DB_HOST ,DB_USER ,DB_PASS ,DB_NAME);\n\n  if (mysqli_connect_errno($connect)) {\n    die(\"Failed to connect:\" . mysqli_connect_error());\n  }\n\n  mysqli_set_charset($connect, \"utf8\");\n\n  return $connect;\n}\n\n$con = connect();<\/code><\/pre>\n\n\n\n<p>The&nbsp;<strong>api\/list.php<\/strong>&nbsp;script receives a&nbsp;GET&nbsp;request from the Angular side of the application and returns the list of cars stored in the database.<\/p>\n\n\n\n<p><strong><u>list.php<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/**\n * Returns the list of cars.\n *\/\nrequire 'connect.php';\n    \n$cars = &#91;];\n$sql = \"SELECT id, model, price FROM cars\";\n\nif($result = mysqli_query($con,$sql))\n{\n  $cr = 0;\n  while($row = mysqli_fetch_assoc($result))\n  {\n    $cars&#91;$cr]&#91;'id']    = $row&#91;'id'];\n    $cars&#91;$cr]&#91;'model'] = $row&#91;'model'];\n    $cars&#91;$cr]&#91;'price'] = $row&#91;'price'];\n    $cr++;\n  }\n    \n  echo json_encode(&#91;'data'=>$cars]);\n}\nelse\n{\n  http_response_code(404);\n}\n<\/code><\/pre>\n\n\n\n<h4><a>#<\/a>&nbsp;Conclusion<\/h4>\n\n\n\n<p>In this tutorial  about developing an&nbsp;<strong>Angular and PHP application<\/strong>, we laid the foundations for building the app. We explained what is a service and why it is a good thing to put the methods that communicate with the server in a dedicated service. You learned about the&nbsp;<strong>HttpClientModule<\/strong>&nbsp;that Angular uses to communicate data via AJAX and that it is based on the pattern of&nbsp;<strong>Observable<\/strong>. We also started writing the code for the PHP backend which supplies the API for the app.<\/p>\n\n\n\n<h4>reference<\/h4>\n\n\n\n<p><a href=\"https:\/\/phpenthusiast.com\/blog\/\">https:\/\/phpenthusiast.com\/blog\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn to code Angular app with PHP backend In the following tutorials, you&#8217;ll learn how build a whole application , with Angular (Frontend ) &amp; PHP ( Backend) . We will create an easy CRUD application ,to add, update, and delete items. #&nbsp;1. Install Angular The first command installs the&nbsp;Angular\/CLI&nbsp;working environment, and the second generates [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":322,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37,26,9,51],"tags":[40,54,52],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/315"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":7,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/315\/revisions\/1707"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/322"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}