Submit Your Article Forum Rules

Results 1 to 9 of 9

Thread: php cli

  1. #1
    WebProWorld MVP chandrika's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    742

    Question php cli

    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

  2. #2
    WebProWorld MVP danlefree's Avatar
    Join Date
    Jun 2005
    Posts
    414

    Re: php cli

    • 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).
    Dan LeFree | Owner/Operator (Web development, marketing)

  3. #3
    WebProWorld MVP chandrika's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    742

    Re: php cli

    Thankyou, much appreciated.

  4. #4
    Senior Member
    Join Date
    Dec 2007
    Posts
    212

    Re: php cli

    Hi,

    Use PuTTY to connect to the server. Then from the command line, enter
    Code:
    php /path_to/your_script.php -q
    Works fine on many popular hosts.

    Jean-Luc
    200ok.eu Broken Link Checker finds 404 errors, error pages with 200 ok status, missing images, protocol errors, password protected pages, bad domain names, redirect loops, parking pages, ...

  5. #5
    Senior Member Uncle Dog's Avatar
    Join Date
    Apr 2008
    Posts
    342

    Re: php cli

    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

  6. #6
    WebProWorld MVP chandrika's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    742

    Re: php cli

    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

  7. #7
    WebProWorld MVP deepsand's Avatar
    Join Date
    May 2004
    Location
    State College, PA
    Posts
    16,443

    Re: php cli

    Quote Originally Posted by chandrika View Post
    I probably need more sleep
    Sleep? What's that? A new energy drink?

  8. #8
    Senior Member Uncle Dog's Avatar
    Join Date
    Apr 2008
    Posts
    342

    Re: php cli

    Quote Originally Posted by chandrika View Post
    ...so actually can i use phpmyadmin as CLI
    Not really the right question. So Admin Panel 2: phpMyAdmin - Uniform Server Wiki System will probably help you see the difference.

  9. #9
    WebProWorld MVP chandrika's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    742

    Re: php cli

    Quote Originally Posted by deepsand View Post
    Sleep? What's that? A new energy drink?
    LoL
    no, but it should be, i would buy it and drink it if it were on sale.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •