How to run my php file from mac terminal?

To run a PHP file from the Mac terminal, you will need to have a web server installed, such as Apache, and PHP should be configured correctly with the server. Once you have those set up, navigate to the directory where your PHP file is located in the terminal, and type "php" followed by the name of your file, like this:

php myfile.php

If your PHP file is designed to output something, you should see the result in the terminal.

Watch a course Learn object oriented PHP

Another way is to use the built-in server of PHP by running the command:

php -S localhost:8000

This will start a server on localhost on port 8000. Then you can access the file by going to http://localhost:8000/myfile.php on your browser.