Hello guys, welcome to the third session of the PA Dotty a tutorial for beginners. In this session we will create the V book using the PHP and deploy it in Google Cloud. I am already installed the SMP in my system. Here is the Astra Doc's dx. Within that I am going to create a new directory named wave hook. Within that, again, create a new directory named wave.
And now create a new file name fulfillment dot php open with the sublime text and write the PHP tag. In case of PHP to retrieve the data from body we need to use the fire get content Within that we need to write the PHP, Koran forward slash forward slash input to the to the data from the body and decode this Jason data by using the Jason underscore decode method and retrieve it in the variable name request. First of all, I'm going to retrieve the year two numbers which are passed in the JSON or pyramidal within the result attribute. For that write the request reserved para meters and our parameter name that is a number one and reiterating the variable name number one Quality number two and the Create a one variable name speech, which contain the method that we are going to return. We will return the sum off number one and number two is origin.
So, number one plus number two. After sum we need to create the error response for that write the response equal to the array which contain the speech It will be a speech and for the display text, it will be speech again and said the content type for the desert to the application slash Jason and we need to display the response in the JSON format. Save it and lead in the local environment. For this I'm going to use the postman. If you don't tell link is available in the description and paste the URL of the local hospital that we created and change the request type to the bushed. We need to send the raw data in the JSON format in the request.
Vivid it really is is ended up from the apa.ta. O folder ideas some more than and 20 and hit the enter button. Click on the association. Here is the facts of the ages and data which we will be sending in the our request copy and the paste it here and click on the send button. Here you can see that we got the sum of 10 and when he is 30. After he is successfully testing in the local environment now we will deploy it in the Google Cloud.
For these I am already downloaded and installed the Google SDK. Link is already available in the description. To deploy the PHP app on the Google Cloud, we need to create an app dot yamo file At the root level. So let's switch to the root and create a new file dot html. Within that we need to specify the runtime will be a PHP and women will be the flex runtime configuration will be the as the below document. Load will be the web directory.
Save it and open the command prompt from the root directory. Write the CMD write the G Cloud in it yeah, it will As for the login, press the Y it will open the login page in the browser. Log into the Google account in which you are signed up for the Google Cloud. At the time of recording, Google Gt 300 USD free for the one year. For most of case it will be sufficient allow access to the app. After the logging, we need to pick the project that we are going to use.
I am already created the new project named the fulfillment in the Google Cloud for the fulfillment demo. So I am going with the one we need to enable the Google API's for that. app that is we need to select the server or the gym where you want to deploy idea. I'm going to, I'm going to use the 24. To deploy the apps we need to write the G Cloud App deploy. Here is the issue occur with the region that I was selected because these reason does not support the PHP.
So I need to select the another. I'm going with the Asia. And if you want to deploy on the same URL or the everything DSM project places he takes some time to update the services. Our app is deployed on the server. To see it, we need to write the G Cloud App browse. It will open the UI in the browser.
And because of we created the file name full filament, we need to open it. And now they should with the postman. Here we got the response. After creating the web hook, we need to update the URL in the fulfillment section of the API dot d, on the fulfillment and paste the URL here, click on the Save button. And write some of 10 and 20. Here we got the sum of 10 and what is 30?
Let's try with here the numbers sum of 50 and 80. We got the sum of 50 and 80s 130. Let's see what we learn in this session. First of all we are create the fulfilment dot php in which retrieve the data from the body of the request and perform the operation based on it and return the sum as the Jason throughout this series I will perform the only basic operation and here I am not performed the any validation was I am going to show you how to retrieve the values from the request and give the response. After creating the PHP application, we need to deploy it in Google Cloud. For this, we need to To create the app dot Yama, in which we specify the runtime is the PHP and environment will be the flag.
And the application root will be the lib directory. To deploy the app, first of all, you need to create a Google Cloud account and download the Google Cloud SDK and use the G Cloud init command and log into the your Google account. Then select or create the project and region server. And don't forget to make the project billable. Then create the AB dot yamo file as per the previous side and use the deploy command to deploy the our app and use the Browse command to browse in the browser. And don't forget to update the fulfillment details in the APA Dotty I.
Thanks for watching. Have a nice day. If you have any doubt feel free to contact me