Jump to content

[SOLVED] PHP - Windows CLI


kevinkorb

Recommended Posts

I have PHP 5.2.3 running on Windows Server 2K3.

 

Everything works fine through apache, however I'm creating some automated tasks and wanted to us Windows Task Scheduler to run them through the command line.

 

Test 1: - Send simple email:

 

<code>

<?php

mail("kevin@mydomain.com", "test email sub1", "test body", "From: testserver@test.com");

?>

</code>

 

Now I tried running that three different ways.

 

(I have a copy of the php.ini in the same folder as the script I'm running)

 

I tried:

php test.php

php -n test.php

php-win test.php

 

The only one that completed and sent the email was php -n test.php.

 

Then I ran a simple test to try to connect to my database.

 

After trying to run it every way I thought I could, the error message came back that it couldn't instantiate the mysqli class.

 

So I imagine it is a php.ini problem, however I'm not able to resolve it in any way.  Any ideas?

 

thanks

Link to comment
Share on other sites

That does work, however I'm looking for a 'best practices' solution.  The box is going to be working very hard to begin with (The mysql database is at about 25 million rows in 130 tables) the budget is decent for the project, I would really not want to resort to ie for automated tasks.

 

You solution would work, however I'm looking for a bit more.

 

Thank you.

Link to comment
Share on other sites

I can create a simple .bat file containing...

 

php d:\www\vhosts\mydomain.com\myfiletoautomate.php

 

and then Schedule that through the task scheduler.

 

That part is easy, its just getting php to play nicely in the command line format that is the problem.

Link to comment
Share on other sites

I figured it out.

 

I copied my php.ini file to the same folder and then gutted the extensions except for mysqli (which I will defiantly need).

 

Then to call the php script I used:

 

php -c php.ini test.php

 

It worked.

 

I'm chalking it up to an extension(s) that isn't compatible with the php cli for windows.

 

Way too much fun for what I wanted to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.