How to access and run PHP with command Line in Windows

You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory.

To add it to path (The best approach – Edited for Windows 7):

  • Right-click on a My Computer icon
  • Click Properties
  • Click Advanced system settings from the left nav
  • Click Advanced tab
  • Click Environment Variables button
  • In the System Variables section, select Path (case-insensitive) and click Edit button
  • Add a semi-colon (;) to the end of the string, then add the full file system path of your PHP installation (e.g. C:\Program Files\PHP)
  • Keep clicking OK etc until all dialog boxes have disappeared
  • Close your command prompt and open it again
  • Sorted

Alternatively, you can run cd <PHP installation path> before you try and run you command, or call your script like <FULL file system path of php.exe> <path to script>


  1. How to access PHP with the command Line in Windows
  2. Run php file in windows cmd

SMTP gmail on Codeigniter 3

I got this article from stackoverflow as always 😀

Use the following code

And dont froget to unable following two security settings in google.

1) << turn it on

2) << Click continue

** Turn off 2 step verification if you have it enabled.

Code :

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://',
        'smtp_port' => 465,
        'smtp_user' => '',    //email id
        'smtp_pass' => 'xxxxxxxxxxx',            // password
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    $this->load->library('email', $config);

    $this->email->from('','my name');
    $this->email->to(""); // email array
    $this->email->subject('email subject');   
    $this->email->message("my mail body");

    $result = $this->email->send();

    show_error($this->email->print_debugger());  // for debugging purpose :: remove this once it works...