LoginSignup
2
3

More than 5 years have passed since last update.

CodeIgniter内のPEARを使うようにパスを通す

Last updated at Posted at 2015-03-03

PEARのHTTP_Request2を使ってみる
でライブラリを作って自作APIを叩くようにして、batchでぐるぐる回そうとしたら、エラーがでた。

エラー

require_once 'mylib.php';
Class

$data = mylib::getdate();



PHP Fatal error: require_once(): Failed opening required 'Net/URL2.php' (include_path='.:/usr/local/lib/php:/php/includes:/usr/local/php-5.2.17/lib/php/) in /app/app_name/libraries/PEAR/HTTP/Request2.php on line xx

が出た。

対処

パスが通ってないのでパスを通してあげる。

例えばPEARのディレクトリを

define ('PEAR_PATH', 'libraries/PEAR/');

としてあげて、

set_include_path(get_include_path() . PATH_SEPARATOR . PEAR_PATH);

すればPEAR_PATHが通る。

get_incude_path() で現在のpathが取得できて、

PATH_SEPARATORで
Windows →;
それ以外 :
が取得できるので

現在のpath:PEAR_PATH
でPATHを通すことが出来る。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3