Tutorial - How to run PHP Programming Language in Command Prompt (CMD)

in #utopian-io7 years ago (edited)

What is the purpose of this tutorial?

  • Running PHP (Hypertext Processor) in CMD.

Requirements

Remember : For all the requirements, choose according to your computer architecture.

Difficulty

  • Basic.

Preliminary

Here, I will share how to configure Windows to recognize the php command in CMD. So it can be used for advanced composer and web development. The trick is actually very simple. Just enter the location (path) php into Environtment Variables only. This will look like we are running php in the linux terminal.

So, let's get started.

Procedures

1. Install the Software
Previously installed both software (the requirements) . How to install it as usual without any additional special tools and just press the next to complete.

If done then go to the next step.

2. Find Installed PHP Locations
After it has finished installing xampp, it then goes to the system directory (or directory C) and see xampp folder.
folderxammp.PNG

Then open the xampp folder, then open the php folder inside the xampp folder. usually are on c:\xampp\php.
phpfolder.png
This location will be used as the path address in the Environtment Variable.

2. Run System Properties
To run this process, press Windows + R key on the keyboard. Then the Run window will pop up and type this command below. Click OK if done.

%windir%\System32\SystemPropertiesAdvanced.exe

jendelarun.PNG

3. Enter to Environtment Variables
Press Button Environtment Variables.
ev.PNG

4. Edit the Variabel Path
Select a path variable first, then click the Edit button.
ev2.png

5. Enter PHP Location
To add a value, make sure the edit Environment Variables window opens and click the browse button on the right.
editev.PNG

After the browser window, open the C directory, then open the xampp folder and then click on the php folder (C:\xampp\php). Click OK.
browse.PNG

After that, there will be a new value that we have added earlier in the value list in the edit Environtment Variables window.
newvalue.PNG

And then subsequent to this step, Click OK and close System Properties window.

6. Experiment PHP Commands in CMD
Try typing the php --version command in the CMD. If the result is like the picture below, it means the php command has been successfully recognized on the CMD.
phpcmd.png

7. PHP File Execution Trial
Now, try to make file phptest.php. make it on Notepad++ which has been installed earlier.
phptest.PNG

and save it on E diretory.
filephptest.PNG

After that, execution via CMD. Before executing, go to E directory.
E.png

Afterwards, type php phptest.php and click enter. If successful, will display the contents of the file as shown below.
E hasil.png
Congratulations, Now PHP can be run through CMD.

Curriculum

This is the first tutorial i'm contributing using PHP.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

No matter approved or not, I upvote and support you.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @simpleawesome I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x