How To Run PHP Projects in XAMPP Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so let's see how we can do it so first of all open your favorite browser and search for xampp and the first link which will appear here will be from apachefriends.org so we are going to click on this link and once you are on this xampp website you will be able to see the download button for xampp for windows linux and mac os so we are interested in the windows version so straight away you will be able to see this xampp for windows option so just click on this which is going to start the download of this xampp windows dot exe file so just wait for the download to complete so once this executable file is downloaded i'm going to click on this and then i'm going to minimize my browser which is going to start the xampp setup window so first of all you will see this kind of warning do you want to allow this app to make changes on your device i trust this app so i'm going to click on yes here now you can see the setup window is going to start now first of all it's going to show you this kind of warning it says important because an activated user account control on your system some functions of xampp are possibly restricted so just ignore this warning for now and then click on ok which is going to start this setup window and then we are going to click on the next button here and xampp server is going to come with all these tools so it's going to come with apache server mysql filezilla ftp server mercury mail server and tomcat and languages which are supported by xampp server is php and perl and the program languages are php myadmin webalizer and fake send mail so i want all these components so i'm going to leave everything as default and then click on next and this will be the location where xampp will be installed so if you don't have the good reason to change this location just leave it as default and then click on next and then you can choose the language in which you want to install xampp server i'm going to select english here and then click on next and then click on next and at this point it says how do you want to open this so i'm going to select the browser of my preference which is google chrome and then click on ok which is going to start this kind of webpage here which says say hello to favorite applications on xampp i'm going to minimize this browser and then click on next here we're just going to start the installation process of xampp on my windows 11 operating system so at this point you just need to wait for this progress bar to reach to the 100 mark and while the installation process is going on you will also see this kind of warning so i'm going to just click on allow access at this point so after some time you will see this message which says completing the xampp setup wizard and here you will also see this check box which says do you want to start the control panel now so i'm going to leave this check box as checked and then click on finish which is going to start the xampp server on my windows 11 operating system so you can see the xampp server control panel window has been started you can also open the xampp server from the list of all these apps on your windows 11 operating system so when you will scroll down here you will be able to see the xampp server here under zamp folder okay so you can see this is the control panel which is opened right now so you can always uh go to your windows start menu and then open the sam server from here once the sam server is started you will see this kind of window also you will be able to see uh this icon which is created here which is for exam server so it also indicates that xampp server is running so on this xampp control panel window you will be able to see all these modules the apache module mysql filezilla mercury and tomcat and you will be able to see some button in front of all these modules so the first section is for the start button or the stop buttons and then the next section is for the config button so you can configure all these modules using this config module and you can also see the individual logs of all these modules so if they have any errors you will be able to see in the logs right so let's start the apache server first of all so in front of apache i'm going to click on the start button which is going to start the apache server right once the apache server starts you will be able to see that here you will be able to see the green color around this apache that means everything is running successfully once the apache server is running you will be able to see the stop button for stopping the purchase server you will also see the pids so using these pids you know on which pids this apache server is running so if you want to force kill the purchase server you can use these pids right you can also see the config and logs which i'm going to cover little bit later you will also see these ports so these are the default ports on which the purchase server starts so if by chance these ports are not free on your windows 11 operating system then your apache server is going to show the error and i'm also going to show you how you can solve that error but first of all our apache server is running on port 80 so we can go to our browser and then here i can just write local host and then press enter and if you see this kind of window that means apache server is running successfully on your windows 11 operating system and it's working fine right so you can see i have opened the local host on which apache server is running and it has opened the dashboard on the apache server so everything is working fine for the apache server also in this web page you will be able to see this php my admin so when you click on the php my admin it should open the php my admin window but for now it's not going to show you the php my admin window and it's going to show you this error why it's showing this error because we haven't started our mysql server here right so you can see mysql is not started so we have to start mysql in order to see the phpmyadmin interface so let me just click on the start button here and then i'm going to click on allow access here and now you can see my mysql server is also running on port 3306 and i can stop this mysql server at any time now my mysql server is running so i'm going to refresh this webpage once again for phpmyadmin and you will see that this php my admin window and it's going to show you this kind of interface that means your php myadmin is also working from here you can create databases you can run sql queries and do many things related to your database right so that's running now remember i have told you that if this port 80 is already occupied on your windows operating system by some other service this apache server is going to show you some errors so first of all how you can check which ports are already occupied on your windows 11 operating system so xampp control panel comes with this netstat tool so when you click on this netstat button it's going to show you the list of all the ports which are occupied on your windows 11 operating system so you can see port 80 is occupied right now by my apache server but let's say if it's occupied by some other service it's also going to show you the name of that service right similarly you can see mysql is running on port 3306 and you can see all the other ports which are occupied on your windows 11 operating system with all these services right so let's say this port 80 is already occupied so i want to change this port of apache server so for changing this port you just need to stop your apache server first of all and then click on config here so for the configuration you can choose the first option which is http file so i'm going to click on the first option which is going to open this kind of file so on this http.conf file just scroll down a little until you see this listen keyword right so you can see the default port right now is 80 i can change this port to something else so let's say i want to change this port to port 8080 8080 right i can also change this but it will not change anything because you can see this line is commented right so you need to change this port in order to change the port of your apache server and then just save this file by pressing ctrl s and then you can close this file once that's done you can once again start your apache server so click on the start button and this time you will see that now the port of apache is changed to port 8080 in my case right so this is how you can change the port now once again when you go to your browser and type localhost here this time it's not going to open because now our server is running on the different port right so if the port is 80 on your windows operating system you don't need to provide any port information on the browser but if you change the port from port 80 to some other port in our case we have changed it to port 8080 i need to add this colon and then add the port number in my case it's port 8080 and then press enter and then only it's going to open right so you need to write the port number after the local host in order to open this web page if you changed the port here so the port should be similar which is visible here on this browser after local host similarly this php my admin is also not going to work right why it's not going to work because you guessed it right you need to add colon 8080 after the local host and then press enter and then it's going to work normally right so if you change the port here you need to change the url also here once these two servers are running just minimize this window now we need to go to the location where we have installed the xampp server by default it's installed in the c directory so i'm going to go to my c directory and then i'm going to just go under this xampp or xampp folder so click on this xampp folder and then here you need to go inside this htdocs folder so once you are inside this htdocs folder you can create any folder of your choice where you want to save all of your php files so you can right click here and then create a new folder and name it anything so i'm going to name my folder as my app you can give any name to your folder in my case it's my app and then i'm going to press enter and then i'm going to go inside my folder now in here you can create a php file so in order to create a php file on windows you need to create a text file and then change the extension of it otherwise you can open visual studio code here right so right click here and then click on show more options and you will be able to see this option which says open with code so just click on this option which is going to open this folder my app in visual studio code otherwise if you don't want to open it from here you can just open visual studio code first of all and then you can just copy the path of your folder which you have created recently and then click on file and then click on open folder and then just give the path here and then and then click on select folder which is going to open the same folder right so once you have opened this same folder which is essentially this folder which we have created you can see this folder name is my app here we can create our php file so i'm going to name my php file as test dot php here okay and then press enter and at this point visual studio code is going to recognize that you want to write some php code and you can see cannot validate since a php initialization could not be found use the settings php a path to configure this php executable right so for now we are going to uh just close this window otherwise if you want to set the php exe file then you can click on the open settings option but we want to run php using the xampp server right so we are using right now visual studio code as just the editor and everything will be taken care by our xampp server so here you can just write a very simple php hello world program like this which just prints hello world in order to test whether it's running or not and once you are done just save your file and once the file is saved we can go to our browser and then just type localhost and if you have added some port you can also type some port here you can know the port on which your apache server is running by just viewing this port under port you can see it's running on port 80 in my case and by default the local host will run on port 80 if it's running on any other port you need to type colon and then the number of port if it's running on port 8080 then you just need to type the port number here right you can just type localhost colon 80 which essentially mean localhost and then i'm going to press enter here you can see the apache server is running now in order to see your php file what you need to do you need to just open the same folder structure so you need to type the name of your folder which is my app and then test.php right so instead of dashboard just write the name of the folder in which your php file is there and then the name of your file which is test dot php in my case right and then press enter and it's going to show you this result which is hello world and you can see what we have printed hello world right i can also add some more text here and then save this file and then i can just refresh this file and it's going to show me the output right so this is how you can run your php files with visual studio code on your windows 11 operating system now if in case you want to run your php files using command prompt or command line then what you can do so for that you might need to add the php in your environment variables right so if you have installed xampp the path for php executable file is you once again need to go to your c directory and then go under zamp folder and here you will be able to see the php folder right so here you will be able to see all the php related files and you can use php.exe to run your php files right so just copy the path in which your php.exe file is there and if you have installed the zamp and if you have installed the zamp in the c directory just copy this path which i have copied and then just click on the search icon here and then just type environment variables so just type environment and once you type few letters of environment you will be able to see this option which says edit the system environment variables so i'm going to click on this and it's going to open this window so here just click on environment variables and then select the path environment variable under system variables and then click on edit or double click on it here we are going to add a new environment variable and then just paste the path which we have copied which is the path of our php directory inside our xampp folder okay i'm going to press enter here and then click on ok ok and ok so once you have set the environment variables you might need to restart your visual studio code so i'm going to just exit visual studio code and i'm going to restart my visual studio code in the same directory in which my php file is there in my case it's my app and in my app i have this test.php file right now once i have restarted my visual studio code i can open the terminal from here so i'm going to click on terminal and then new terminal and here you can see it has started this powershell terminal for me and in the right hand side i can see the list of all the terminals right so once again terminal new terminal and by default because powershell is the default terminal on my windows 11 operating system it opens the same folder in the powershell if you are not a fan of powershell you can also open the command prompt from here so click on arrow command prompt and it will open the command prompt now if you know some php commands you might also know that in order to run your php file you can just type php and the name of your file which is test.php in my case and then press enter and you can see it prints the output which is hello world so this was possible because we have set the php environment variable right if php environment variable is not set this command is not going to work right and if it's not working just restart your visual studio code once again and try it so if you want to test small php scripts you can directly test these scripts from here otherwise you can always use this browser where your output will be shown right in addition you can also install some popular extensions related to php right so when you uh just click on this extensions icon here you will be able to see the extensions which are popular you can also search for the extension for php just type php in the search box and it's going to show all the popular php related extensions so you can see this one is most popular here and it's developed by x debug and the number of downloads here is around 6 million right so you can click on install and then just install this extension and this will help you to debug your php code using visual studio code editor you also have the other popular extensions for let's say php code intelligence for visual studio code and php extension pack is also here so in this php extension pack some popular packs are here for example php debug and php intellisense so you can install all these uh popular extensions and then uh just try to use this extension in order to debug your code or run your php scripts right so this is how you can run php files on your visual studio code i hope you've enjoyed this video and i will see you in the next video
Info
Channel: ProgrammingKnowledge2
Views: 62,635
Rating: undefined out of 5
Keywords: Visual Studio, Visual Studio Code, windows 11, vs code, PHP, How to Set Up PHP, PHP in Visual Studio Code, PHP Development environment, Set Up, Install PHP, Visual Studio Code for Windows 11, PHP Development, PHP with VSCode, VSCode, PHP IDE, Visual Studio Code for PHP, Debugging PHP, PHP extension for visual studio code, how to run PHP code in visual studio code, PHP interpreter vscode, visual studio code PHP download, XAMPP, XAMPP Server
Id: Op5TTJPCtso
Channel Id: undefined
Length: 23min 5sec (1385 seconds)
Published: Mon Feb 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.