View Full Version : php cli
chandrika
11-09-2009, 03:59 PM
I am doing a tutorial that requires me to use php command line interface and I am not sure wether I will have such on a shared host, or where to find it.
The way I understand it is that its a bit like putty but on a server...but I am not realy sure?
I hope the question isnt too stupid... :s
danlefree
11-09-2009, 06:45 PM
bash - This is the operating system shell, analogous to when you run the command "cmd.exe" to access the Windows shell
ssh - This is a networking protocol which allows you to securely communicate with the bash shell running on a remote machine (you run an SSH client like PuTTY, your server runs an SSH daemon)
PHP - This is a script interpreter - it will not do anything without a script (in much the same way that a web browser won't do anything until it is given an HTML document to open or a video player will not do anything until you open a video file)
PHP CLI - This could mean that you are invoking the PHP script interpreter from the bash shell (aka command line interface) on an existing script over SSH (i.e. type php filename.php from an SSH session) or that you are sending commands (line-by-line) to the PHP interpreter through the bash shell over SSH (not a common way to use PHP but it does exist) - in either case, your PHP installation will need to support this type of access (most shared hosting servers will support PHP as an Apache Module - CLI is not included by default)
You need access to bash to run PHP in CLI mode, which would mean that your user account on the server would need to be allowed to log in.
The cPanel software supports the ability to allow users shell access, though I do not know of many shared hosting providers who have this option enabled (there are many security concerns and I would not want to host anything important on a shared server where others had shell access).
chandrika
11-10-2009, 09:29 AM
Thankyou, much appreciated.
Jean-Luc
11-10-2009, 10:16 AM
Hi,
Use PuTTY to connect to the server. Then from the command line, enter
php /path_to/your_script.php -q
Works fine on many popular hosts.
Jean-Luc
Uncle Dog
11-10-2009, 11:26 AM
Maybe not quite as simple initially but I'd recommend installing PHP on your own PC, then you can CLI to your heart's content.
PS: While you're at it why not got the whole hog and install Apache, MySQL and phpMyAdmin too. Install Apache, PHP, MySQL and phpMyAdmin on Windows (http://www.bicubica.com/apache-php-mysql/index.php)
chandrika
11-10-2009, 09:48 PM
Ah right, yes I have putty so I can just use that as a PHP CLI to a script on the host. That will be easiest.
I will think about installing apache etc here, i can use an old laptop i guess and network it. I already have access to php myadmin on host, so actually can i use phpmyadmin as CLI, it may just be i got blinded by this term php cli in the tutorial as it was saying about installing it, so i was thinking it was something new i needed to install, that actually i may already have.
I probably need more sleep and it will all become clear.
Thanks guys
deepsand
11-10-2009, 10:09 PM
I probably need more sleep
Sleep? What's that? A new energy drink? :confused:
Uncle Dog
11-11-2009, 04:29 PM
...so actually can i use phpmyadmin as CLI
Not really the right question. So Admin Panel 2: phpMyAdmin - Uniform Server Wiki System (http://wiki.uniformserver.com/index.php/Admin_Panel_2:_phpMyAdmin) will probably help you see the difference.
chandrika
11-13-2009, 05:34 PM
Sleep? What's that? A new energy drink? :confused:
LoL
no, but it should be, i would buy it and drink it if it were on sale.