Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: OSX PHPCS Error

 Warning: include_once(PHP/CodeSniffer/CLI.php)

I was dealing with this phpcs error last Sunday. occurs when I updated my PHP and updated System Packages also not sure what was the actual issue, whether something got reset but at the end, my problem was phpcs giving me Fatal Error 🙁

Since I am not much familiar with command line because I just moved from Windows to Linux. but along with time, I am getting better and better at dealing with commands 🙂
Seriously, I call it my best decision when I plan to switch from Windows to Linux/ Unix, because Now I am feeling like I am much productive, not have to deal with windows update, Virus problems, GUI ClickClickClick  annnndddd …….

So, after digging got the problem was due to include_path not specified in php.ini file from
https://github.com/squizlabs/PHP_CodeSniffer/issues/1441
but still, the problem not solved so easily so I thought to share what I did to solve it.

Solution:

So, If you will check the above link the problem will be clear for you or maybe it will work for you if you follow different comments there. I will tell you the solution in my word here.

The above is caused when include_path variable is not specified in php.ini file.

Step 1:

Add Include_Path in php.ini

Verify if the include_path variable is already added

If you have already set the path of pear php executable folder means the include_path is already set then move to step 2.
else If not then

specify the include_path in php.ini

Check the actual and in used php.ini file path

check the pear php executable file path

 

Now, you will need the output of both above commands to set the include_path in php.ini
try command below but specify the output of above command properly in place.

echo 'include_path = ".:'pear config-get php_dir'"' | sudo tee -a php.ini_path

pear config-get php_dir :- output of this command tried above
php.ini_path :- Actual path of your php.ini file got above.

Step 2:

If the problem is yet not solved for you and still getting fatal then now time to set symlink of pear php executable folder

for me the pear php configuration path was
/usr/local/pear/share/pear

It may be different for you based on the output of pear config-get php_dir

Run the above command and now check 

Step 3:

If the problem still persists for you then time to do the final smash here.
I am sure it will 100% fix your problem. If not put it in the comment, I will happy to solve it for you personally.

  1. Change directory to /etc with command  cd /etc
  2. look for php.ini file there if not exist create one copying php.ini.default with command
    cp php.ini.default php.ini
  3. Now add the pear path in that php.ini file with command inside /etc directory

The Error is gone, so let’s enjoy and move forward …

If you have any question, Please ask in the comment because I have done through many articles, so I can help you here quick.
check my few other posts related to WordPress Top Posts by Google analytics How to add menu Item programmatically in WordPress?

Leave a Reply

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