3

I'm currently working on a website. I used the host's control panel to activate several php modules. Now when I try to use them it returns

Fatal error: Class '...' not found

I checked phpinfo() and the classes appear there, but when I do php -m, they are missing. The server uses Nginx.

What can be the problem and how can I fix it?

8
  • 1
    There should be two ini files for cli and apache module. Run php --ini Commented Nov 19, 2016 at 16:59
  • @mazedlx Done that, here is the output: Loaded Configuration File: (none) Scan for additional .ini files in: /usr/opt/php56/etc/php Additional .ini files parsed: (none) BTW, The server uses nginx Commented Nov 19, 2016 at 17:05
  • This means that your cli php does not use any ini file. Ok, so please tell us what modules you are trying to use, show the phpinfo() output and your code. Commented Nov 19, 2016 at 17:09
  • @mazedlx I'm trying to use Imagick, the phpinfo() output is quite long it can be found here Commented Nov 19, 2016 at 17:11
  • 1
    @Rizhiy You can specify the source of your php.ini file when running cli Commented Nov 19, 2016 at 17:13

1 Answer 1

1

Your PHP web installation and your PHP cli installation can be two completely seperate things, and hence they usually have their own ini configuration files.

As per your comment, this is the output you get from your CLI phpinfo:

Loaded Configuration File: (none) 
Scan for additional .ini files in: /usr/opt/php56/etc/php 
Additional .ini files parsed: (none)

As you can see there's no "Loaded Configuration File". As per this post you can specify what ini file to load when running cli scripts.

Since your regular web installation says:

Loaded Configuration File   /home/a2869511/etc/php.ini

Then you can automatically have your CLI program execute with the same ini file:

php --with-config-file-path=/home/a2869511/etc/php.ini script.php

That said, I would recommend that you take a copy of the ini file and place it where your cli application is looking for ini files, which is in /usr/opt/php56/etc/php ("Scan for additional .ini files in").

So the short solution would be to do the following copy:

cp /home/a2869511/etc/php.ini /usr/opt/php56/etc/php/php.ini
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.