How to Run PHP in Visual Studio Code on Windows 11

미연

·

2022. 4. 7. 12:00

hey guys if you're looking for how you can run php programs in your favorite visual studio code then you are in the right place watch this post until the end because i'm about to show you step by step process to configure visual studio code for running php programs correctly and i'm also gonna show you how you can run two basic php program in visual studio code on windows 11. so without further ado let's get started firstly we have need to download and install php to download it copy this link i have provided this link in the post description now open up your favorite web browser i am using google chrome here then paste the copied link into the search bar and hit enter this is a step-by-step detailed blog post explaining you how to download and install php on windows 11.scroll up and find step 1. here look for download php and click on this link it will open the official page for downloading the latest version of php for windows right now php 8.0 is available for download to download it click on this zip file link and now you can see php installer zip file started downloading here it will take some time to download once the downloads get finished click on this up arrow and select show in folder we need to extract this file for that click on this file and select extract all then click on browse button and select local disk c now click on new folder button and give a name to this folder i am writing php8 then click on select folder button it should be similar like this one now finally click on extract button it will starts the extraction process it will take some time to complete now we need to add path in environment variable so that we can access php in cmd globally for that open local disk c here open newly installed php directory and click on address bar and finally copy this path let me close all unnecessary windowsnow click on search button and type involvement variables select edit the system environment variables option here click on environment variables button select path and then click on edit buttonand then click on new and paste php path in this blank field then click on ok buttonok again and ok again good job now let's check is this working or not for that click on search button then type cmd and then click on command prompt here type php space dash dash version and press enter as you can see we have the latest php version installed here congratulations you have successfully installed php on your windows 11 machine correctly now open visual studio code if you don't have a visual studio code then you can watch this post to download and install visual studio code on windows 11. now click on extension button and in the search bar type phpand select the first optionnow click on the small install button it will install debug support for php now clear the search field and type code runner and select the first option make sure it is from junhan and click on this small install button you can run the code by pressing control plus alt plus n and to stop the code from running you can press ctrl alt plus nwe can now close all of these windowsnow let's create first basic php program that prints the message subscribe now in the visual studio code for testing we can create a new file by clicking on file then select new file now again click on file then select save as choose your preferred directory i am selecting desktop here give a name to your file i'll name this file subscribe dot php just make sure you don't forget to add dot php at the end of this file otherwise it won't work then click on save start your php program with open angle bracket question mark php then type echo in double quotes type your desired message i am writing subscribe now and add semicolon to terminate the statement close php tag with question mark and close angle bracket don't forget to save your code to run the code you can press ctrl alt plus n or simply click on this play button and it works see subscribe now is printed here if you followed the steps in this post and reached until here i am assuming this method has been working for you so i am requesting you to please like the post and subscribe to my blog it won't cost you anything but it will definitely boost my morale for making more such posts ok now let's create another program which takes input from the user for that click on file then click on new file and again click on file and select save as i'll name this file input program.phpand then click on save ok here i am writing the code for the program that asks the user for its first name and last name and finally prints full name of the user back to the output console by the way you can copy this program from our website i have attached the link in the post description don't forget to save your program before running the code let's run the program by pressing run play button so our code is running but we are not able to see anything here so this is a problem we can solve this problem by clicking on file then select preference then select settings type run in terminal here and go down a little bit and find code runner run in terminal and check this box and cancel the settings and return back to our program now try to run the code it says code is already running to stop the code from running press control plus alt plus m now run the code by pressing run play button let me type my first name here now the last name and now you can see my full name is printed here so this is how you can run php program in visual studio code if you are interested in learning more about php language then be sure to check out beginners php course at the first link in the post description subscribe and turn on the notifications so you don't miss more posts helping you to learn how to code and become a successful programmer and i'll see you in the next post take care hello everyone i welcome you to my blog today i'm going to show you how to run or execute any phd project that you have downloaded from internet so let's begin now before starting i would like to introduce the sponsor for this post cloudways cloudways allows you to avoid wave hosting hassles so that you can totally focus only on your business using that innovative platform you can go live in minutes all you need to do is you need to first simply select your application and then your server and after that you need to just simply select your server side and you are ready to go please use the affiliate link in the description to support geeky script blog and also use our unique promo code geeky to avail twenty percent discount for two months now to run any php project first you need to download that php project right so for that uh if i go to my browser you can see we have a project right this is a php project so we have this php files so i am going to show you how to download it and how to run it in our local system so for that first you need to just you know simply download it so just you know simply download the zip and it will you know going to download it right so after downloading you to just simply you know go to that download directory and here you can see this project has been directly downloaded over here so first step is just right click on it and then simply click on extract all and then just simply click on extract so what it will do is it will you know going to extract your project over here right you can see this project has been rightly extracted over here and these are the files right now just you know simply hit a back button and this is your project right so you have rightly downloaded and extracted your project now the next step is to download zap so go to this page and you will be able to download xampp the latest version is 8.0.13 i have already made a detailed post on how to install xampp so just follow that post and install your xampp right so after you install your xampp just you know simply search with this amp and when you click on this control panel you'll be able to see this window right here you need to start your apache and mysql so just simply click on this start button for apache and mysql right and you have you can clearly see that it has you know rightly started right this apache and mysql now you need to click on this admin button for mysql in my scale you'll be seeing this admin button so just simply click on that what it will do is it will you know going to open this localhost phpmyadmin you can see the localhost phpmyadmin has been rightly opened over here and this is basic and this is basically the interface of our phpmyadmin this is what we call this as a database right so here any data that we are submitting in our php project that going to be stored over here right so this phm admin has been rightly opened over here now just minimize it and also minimize this control panel this control panel job is now finished almost right so after you just you know simply start this apache and mysql your control panel jobs uh almost finished just simply minimize it right and now here remember we have extracted this project just simply right click on it and then just simply click on cut right and then you need to simply go to your c drive then your xampp folder you'll be seeing so in that post where i have shown you how to install xam i have clearly told you that you will be getting this exam folder after installing your xampp right so just simply go inside that folder and then you'll be seeing this htdocs folder right this is very important just simply go inside that folder and here you need to just simply right click on it and paste right so what it will do is it will you know going to paste your downloaded php project over here so if you just simply go inside that folder you can see all files are rightly there now just simply go editor back and then if you just simply again right click on it on your folder then just simply click on rename and then you need to just simply again right click on it and copy so just simply copy the folder path right and then again go back to your browser just you know simply open a new tab and here just simply type local host slash then paste just simply paste that same folder name that we have just copied then enter and you can clearly see that our php project has been started running over here so it is actually running from this code that we have written in this index.php so if i just simply open that file you can see this is the code which is up and running on our browser right we have this submit button with then email address then address gender last name first name everything is there so that is what it is in our browser it is also showing like first name last name gender and here we have a form but upon entering anything if you click on submit it will going to show it up because our database is not connected yet right so for that you need to make your database connection right so if you go to our project folder you can see we have a sql file over here right testdb dot sql right so what you need to do is you need to just you know first open this insert.php file which is basically our database connection where we have made basically you can see in this connection variable we have connected with mysql connect and first we have localhost then root and this is our password our password is blank and finally we have this test database so these four are our parameters right and the last one is our database name you can see that our database name is testdb so just simply copy that database name right and then you need to go to your browser and here in phpmyadmin just simply click on new and then under this create database you need to just simply right click and paste your database name so whatever database name it has in mysqli connect whatever database name it has you need to just simply paste that database name over here and then just simply click on create what it will do is it will going to create our database you can see our database testdb has been rightly created over here now it's time to import our sql file so that all tables and everything that were there going to be imported so for that you need to just simply click on import and then just simply click on choose file and you can see that our project folder has been rightly opened over here if it directly not open then you need to you know navigate to your c drive then your sam folder then http folder and then you will be getting this insertion for form data which is basically our project type and you can see it has rightly opened and here we have this testdb dot sql file right just you know simply select this and then just simply click on open and you can see test db dot sql has been rightly imported so now just simply scroll down and then just simply click on go so what it will do is it will you know going to import everything that was written on that sql file so it is you know i'm going to create our database then there is one you can see our database has been right to created there is also one you know column so that also it inserted right so you can see our college table has been directly created over here so if you just you know simply click on that you can see our first name last name gender address email everything has been properly created right with one data is also there right so now if you just again go back to your project and here if you just simply enter your credentials so i'm good you know give just simple credentials okay so it is geeky and the last name will be script right and then agenda and address india and i am going to give my email address all right and then just simply click on submit and you can see your data has been successfully stored on your database and you can see what data we have inserted right if you go back to your database and if you just simply click on browse you can see that geeky script mail india and email what we have entered there has been directly inserted in our database right so in this way you establish your connection with your php my admin and you set up our project locally on your system right i have already shown you how to download any php project and then how to basically install xampp and then how to launch your project on your local system right so that's basically all about this post friends thank you very much for watching this post if you like this post then please give it a like and so please do share with your friends thank you very much for watching this post and god bless you all