Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0RC4

Bug #12368 Autoloader cannot be found due to include_path override
Submitted: 2007-11-01 05:19 UTC Modified: 2007-11-04 17:02 UTC
From: rquadling Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.0RC1)
PHP Version: 5_2 CVS-2007-11-01 OS: WinXP SP2
Roadmaps: 1.0.0RC2    
Subscription  


 [2007-11-01 05:19 UTC] rquadling (Richard Quadling)
Description: ------------ Hi. phpcs.bat overrides any ini based include_path. So, an autoloader (auto_prepend_file=autoloader.php for example) fails to be found. NOTE. I'm not using a PEAR autoloader, but one of my own (supports multiple libraries as they are all quite different and I've not had time to use PEAR for it yet.) Removal of the -d option allows the script to run successfully. This makes the assumption that PEAR is in the include_dir already. Maybe phpcs.bat should be created with that in mind. If PEAR can be loaded, then there is no need to add the -d option.

Comments

 [2007-11-01 16:58 UTC] squiz (Greg Sherwood)
I'm not sure how I can change the .bat file to handle this case. I don't think I understand why you are having include path problems anyway. PHP_CodeSniffer is designed to be run as a stand-alone script, so the include path should be fine if it was installed via PEAR. If you don't want the include path set, you can always run scripts/phpcs directly using the PHP CLI. It will run even if not installed via PEAR.
 [2007-11-02 07:38 UTC] rquadling (Richard Quadling)
I have an autoloader (not a PEAR autoloader) called auto_loader.php This exists in my includes folder (D:\WebSites\Common\Includes\autoloaded.php) In my php-xxxx.ini files I have ... include_path=".;C:\PEAR\pear;D:\Data\PHP\Includes" and auto_prepend_file = auto_loader.php This means that all my scripts (cli, isapi, cgi) will have access to the auto_loader.php without the need to hard code it and I can move it and update just the ini files include_path. When I run the standalone phpcs script, it overrides the include_path, effectively hiding the capability of loading the auto_loader.php script. Another solution is to not load the auto_prepend_file/auto_append_file files. "C:\PHP5\.\php.exe" -d auto_prepend_file= -d auto_append_file= -d include_path="C:\PEAR\pear" "C:\PEAR\phpcs" %* So, currently, using ... "C:\PHP5\.\php.exe" -d include_path="C:\PEAR\pear" "C:\PEAR\phpcs" %* like ... phpcs C:\ft.php I get ... Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'auto_loader.php' (include_path='C:\PEAR\pear') in Unknown on line 0 If I edit the phpcs.bat to ... "C:\PHP5\.\php.exe" -d auto_prepend_file="" -d auto_append_file="" -d include_path="C:\PEAR\pear" "C:\PEAR\phpcs" %* I get valid output. See http://pear.php.net/bugs/bug.php?id=7196 and http://cvs.php.net/viewvc.cgi/pear-core/scripts/pear.bat?view=annotate line 113 (V1.26 and V1.27).
 [2007-11-02 16:54 UTC] squiz (Greg Sherwood)
Ah sorry, I understand the problem now. Thanks for taking the time to explain it again. I'll apply that patch.
 [2007-11-04 17:02 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.