How do i open a php file on mac?

Late response, but was looking into doing this for myself, this coming up as one of the results in my searching wanted to provide 2 solutions since I ultimately came to both on my own.

Solution #1

The simple way is to go a round about way by writing a wrapper file to execute the script you're working on. Create a file with the following code:

#!/usr/bin/php

Save it as wrapper.command The name wrapper isn't important, but the command extension tells Finder that this is a shell script to open up in Terminal. The file itself just executes whatever php script is in the include.

Solution #2

The specific inquiry requires a bit of work.

First make sure that the 1st line of the php script is:

#!/usr/bin/php

This is where the preinstalled version of PHP is installed on Mac OS X. You can always verify by running this command in terminal:

whereis php

Once you've added the Shebang line to the php script you've readied it for automatic execution.

To make it double clickable executeable you have to do the following: Right click on the PHP script and click Get Info. Click where it says Open With, click the default option to see all the available options. Select Other...

Switch where it says Enable: from Recommended Applications to All Applications, and click the checkbox for Always Open With. Choose Terminal as the application. Finally, you have to click the button that says Change All...

OS X will verify you want it to set Terminal as the default application to open .php files

This will make every php file open up in terminal by default, but unless they contain the #!/usr/bin/php line they won't actually run.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: how to open .php files on mac

when i tried to click to listen to an audio online, i get this message "the flip for mac plug-in needs your permission to run it".

Then i clicked "run" and get this:

"Track.php

QuickTime Player can't open "track.php" because the movie's file format isn't recognized.

To see if additional software is available that will enable QuickTime Player to open the movie, click Tell Me More."

Thanks.

Posted on Apr 24, 2012 7:45 PM

User profile for user: berlydon

Question: how to open .php files on mac

How to Work with PHP programs on macOS / Mac OS X

The macOS / Mac OS X operating system comes pre-installed with the libraries needed to run PHP programs. You can interact with PHP programs via the Terminal application (Applications -> Utilities -> Terminal). You can also use the built-in web server that comes with Mac, the Apache web server, to execute PHP programs. For more information on running PHP via the local web server, see the following:

Running PHP on Apache for Mac

PHP programs can be created using any text editor such as EditRocket. PHP programs and scripts typically end with the .php extension. EditRocket will automatically recognize files with the .php extension as PHP programs, and will color the syntax accordingly.

To create a PHP program, simply create a new file, such as hello.php. In the file, place the following:

The above program can be executed using the EditRocket Tools -> PHP -> Execute Program option, or you can execute it from the Terminal window. To execute the script in the Terminal, use the cd command to cd to the directory where the hello.php file was saved, such as

cd /Users/user/Desktop

Then type the following:

php hello.php

Hello World! should then be printed to the screen.

How to Save PHP Files in Mac TextEdit

Scott-Cartwright/Getty Images

Updated on September 30, 2018

TextEdit is a simple text editor that comes standard on every Apple Macintosh computer. By following a few simple steps, you can use the TextEdit program to create and save PHP files. PHP is a server-side programming language that is used in conjunction with HTML to enhance the features of a website.

Open TextEdit

​If the icon for TextEdit is located on the dock, as it is when the computer ships, just click the icon to launch TextEdit. Otherwise,

  • Open a Finder window by clicking on the Finder icon in the dock.
  • Choose Applications from the menu on the left.
  • In the list of applications on the right side of the screen, find and double-click TextEdit.

Change the TextEdit Preferences

  • From the Format menu at the top of the screen, choose Make Plain Text. If you don't see this option, but see "Make Rich Text," the document is already set for plain text.
  • Select Preferences from the TextEdit menu at the top of the screen.
  • Click the New Document tab and confirm the radio button next to "Plain text" is selected.
  • Click the Open and Save tab and confirm the box next to "Display HTML files as HTML code instead of formatted text" is checked.

Enter the Code

Type the PHP code into TextEdit.

Save the File

  • Choose Save from the File menu.
  • Enter your_file_name.php into the Save As field, being sure to include the .php extension.
  • Click the Save button.

If a pop-up asks you if you want to use .txt or .php as the file extension. Click the Use .php button.

Testing

You cannot test your PHP code in TextEdit. You can test it in PHP if you have it on your Mac, or you can download an emulator app from the Mac App Store—PHP Code Tester, PHP Runner and qPHP can all be used to test the accuracy of your code. Just copy it from the TextEdit File and paste it into the application screen.

How do I run PHP on Mac terminal?

PHP Installation for Mac Users:.
Open terminal or command line window..
Goto the specified folder or directory where php files are present..
Then we can run php code using the following command: php file_name.php..

What programs will open a PHP file?

Programs that open PHP files.
File Viewer Plus..
Adobe Dreamweaver 2021..
Eclipse PHP Development Tools..
Zend Studio..
MPSoftware phpDesigner..
ES-Computing EditPlus..
Blumentals WeBuilder..
Microsoft Visual Studio Code..

How do I open an PHP file?

A PHP file is a plain text file, so you can open it in any text editor like VI, Notepad, or Sublime Text.

Where is PHP on my Mac?

Set the php. ini location or use the default A typical default location on macOS is /usr/local/php/php.