July 3, 2008

CLI has stopped working

CLI has stopped working” is an error that you may encounter when running command-line PHP scripts in Windows.  This has been reported frequently by CakePHP users when their “bake” scripts crash.  My particular experience with this issue occurred while running PHPUnit tests from the command line.

The top search result as well as others indicates that this is a problem with php_mysqli.dll however none of the suggestions on this page helped me.  An experts exchange post indicates that the problem is with libmysql.dll, however I didn’t know where to download the replacement for libmysql.dll.  It turns out that I already had it and the following solves the problem on My Vista and Windows 2003 boxes:

Copy From: C:\Program Files\MySQL Server 5.0\bin\libmySQL.dll

Paste To: C:\Program Files\PHP\ (overwrite the original)

This assumes you installed MySQL and PHP to their default locations.  If not, then use the correct paths for your particular setup.

Prior to this fix, my unit tests were causing the “CLI has stopped working” error at least 50% of the time.  Since replacing the dll file I haven’t seen the error.

10 Comments on “CLI has stopped working

July 13, 2008 at 4:20 am

UPDATE – I recently got the CLI error again so this doesn’t solve the problem completely. However, it did radically decrease the number of times I get it. I’ve since discovered that the CLI happens when using the PEAR library Spreadsheet::Writer – I doubt that library is the cause, but something in there triggers the CLI error frequently.

July 23, 2008 at 11:05 am

This hasn’t helped at all for me. I have replaced libmysql.dll and php_mysqli.dll to no avail. What about php_mysql.dll?

July 23, 2008 at 5:42 pm

I tell a lie, I have got it working. This time I completed replaced the ext directory with the latest from the PHP zip, and it works. I don’t think the problem was libmysql.dll

July 26, 2008 at 3:47 pm

Hey John, what version did you copy? I thought I had fixed the problem for a while – i did not see any errors, but then it turns out it wasn’t totally fixed. The dll update definitely had a positive effect, but I can say for sure it wasn’t 100%.

Bob Wilson
November 19, 2009 at 2:14 pm

Ok, maybe someone can help me. I’ve been trying install Wampserver, but the same thing happens each time. I get “CLI has stopped running” and the program closes. No one has been able to help me. I run a vista Ser.
Pac. 2 on a good running Windows system. Please help. If you don’t know please send me to the right place. The folks at Wampserver are not very responsive.

November 19, 2009 at 5:10 pm

Hey Bob, I wish I knew. I would try installing Apache, PHP and MySQL manually using the latest versions. Personally I like using as many of the OS built-in services as possible so on Windows I prefer using IIS instead of Apache, but of course that has nothing to do with the CLI issue. CLI stands for Command Line Interface if you didn’t already know, which is only relevant when running PHP shell commands so you don’t really see it when running CGI or ISAPI.

May 31, 2010 at 10:57 am

Thanks a lot for the blog jason.
On my vista it is php_exif.dll that causes it.
I should mention that i use a manual installation of php 5.2.5.rather and not a xamp intallation.

September 8, 2014 at 11:24 am

It works perfect! I dont know why this lib couses this behavior (sounds strange, no?) but now its working perfect!
Thanks A lot !!

January 13, 2015 at 11:03 am

i had a similar problem with “saprfc32.dll”, based in your sollution i pasted the file into “C:\Program Files\PHP\ “.

September 15, 2015 at 6:48 am

:-), :-), :-), :-)
the problem was php5ts.dll, with the last change i was able to make it run.
\PHP\php5ts.dll (overwrite the original)
so simple!


Leave a Reply

Your email address will not be published. Required fields are marked *