Question

I have installed Console_CommandLine using pyrus:

php pyrus.phar install pear/Console_CommandLine

the directory where Console_CommandLine was installed has the next structure: (/A_PATH/lib/)

lib/
├── cache
├── data
├── docs
├── downloads
├── php
└── tests

I've tried the next: (/A_PATH/demo.php)

<?php
    require_once 'lib/Console_CommandLine/php/Console/CommandLine.php';
    ...
 ?>

but I have the next error:

PHP Warning:  require_once(Console/CommandLine/Exception.php): failed to open stream: No such file or directory in /A_PATH/lib/Console_CommandLine/php/Console/CommandLine.php on line 32
PHP Fatal error:  require_once(): Failed opening required 'Console/CommandLine/Exception.php' (include_path='.:/usr/share/php:/usr/share/pear') in /A_PATH/lib/Console_CommandLine/php/Console/CommandLine.php on line 32

How can I use the CommandLine.php file for my personal project?

Was it helpful?

Solution

You need to setup your include path. PEAR packages rely on it being set correctly, so that their includes work properly:

set_include_path('.:/A_PATH/lib/php/');

You can also set that in your php.ini, which is how it's done most times.

A howto to setup your include path can be found in the PEAR 1 manual: http://pear.php.net/manual/en/installation.checking.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top