Call to undefined function mcrypt_module_open() in CLI only, works fine when in browser


I'm encountering a weird problem.

I'm using xampp 1.6.4 on a  windows box. I'm trying encryption using the CLI for PHP and gets the error: "Call to undefined function  mcrypt_module_open() in ...."

Running phpinfo (php.exe -r phpinfo();) in the cli does not show mcrypt as enabled. Viewing the same script thru the browser, however, shows mcrypt as enabled.

Please help me in enabling mcrypt in CLI.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Beverley PortlockCommented:
Mcrypt does not always install properly on Windows. Try copying libmcrypt.dll from your PHP root folder (presumably C:\PHP) to \Windows\System32
SWB-ConsultingAuthor Commented:
Thanks bportlock,

I tried this but still got the same error. I copied libmcypt.dll from my xampp\php to C:\Windows\system32 and restarted apache.

Any more thoughts ?
Beverley PortlockCommented:
Ensure that the CLI version can see php.ini or copy php.ini to the CLI folder. From what you report it seems like the CLI version is not loading the mcrypt module.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SWB-ConsultingAuthor Commented:
Hi bportlock,

Thanks You! I was finally able to make it work. The fact is, php cli in xampp has a separate php.ini file inside xampp/php where it gets the config from when using CLI. ( It usese the one in xampp/apache/bin when serving to a browser). Weird, huh ?

Nevertheless, I am giving you the points because you helped me find the solution.
Beverley PortlockCommented:
Thanks for the comment. It's always nice to know .... good luck with whatever you're doing.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.