2
votes

i'm working with ubuntu 11.10 as root on my local machine, i've installed xampp 1.7.7 and i'm a newbie to ubuntu, while following a tutorial on sitepoint(http://www.sitepoint.com/getting-started-with-pear/) on how to install pear to use PhpUnit, i didnt notice it then, but it seems that i installed or used an existing php version 5.3.6 in CL to do that, also the pear installation was built on this version, while xampp being installed,i now have two versions of php,xampp's 5.3.8 and the 5.3.6, anyway, what i want to do is to use the existing xampp php version and build pear on that, to make all my work through xampp.so my questions are:

  1. how to uninstall the php V5.3.6 and it's pear installation?
  2. how to link the CL with the php ver. of xampp?
  3. how to build the next pear installation on the php ver. of xampp?
  4. i want all my web dev. work through xampp, is there anything else i need to unistall, to avoid this confusion? 4.

i did the following in attampet to solve the problem:

  1. i wrote this in bash:

    gedit ~/.bashrc

  2. i added that to the end of ~/.bashrc file in attempt to change environment path:

    export PATH=/opt/lampp/bin:$PATH export PATH=/opt/lampp/lib/php:$PATH export PATH=/opt/lampp/lib/php/PHPUnit/pearcmd.php:$PATH

  3. i checked the php and pear version using 'php -v' and 'pear list' i got an ouput of:

    PHP 5.3.8 (cli) (built: Sep 19 2011 13:29:27) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

and for pear:

Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.9   stable
Console_Getopt   1.3.1   stable
PEAR             1.9.4   stable
PHPUnit          1.3.2   stable
Structures_Graph 1.0.4   stable
XML_Util         1.2.1   stable
  1. when i run: 'phpunit MessageTest.php': i get

    PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38

    Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38 PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR') in /usr/bin/phpunit on line 38

5.i ran the following commands as reported in other questions as a solution to that error:

sudo apt-get remove phpunit
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit
sudo apt-get install phpunit

and updated include path of php.ini to be:

include_path = ".:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR"

the php file MessageTest.php:

<?php
  require 'PHPUnit/Autoload.php';
  $path = '/opt/lampp/lib/php/PEAR';
  set_include_path(get_include_path() . PATH_SEPARATOR . $path);

  require_once 'PHPUnit/Framework/TestCase.php';
  require_once 'Message/Controller/MessageController.php';

  class MessageTest extends PHPUnit_Framework_TestCase{
    private $message;
    public function setUp() {
      $this->message = new MessageController();
    }
    public function tearDown() {
    } 
    public function testRepeat(){
      $yell = "Hello, Any One Out There?";  
      $this->message->repeat($yell); //sending a request
      $returnedMessage = $this->message->repeat($yell);//get a response
      $this->assertEquals($returnedMessage, $yell);
    }  
  }
?>

MessageController class from MessageController.php that i'm trying to test

<?php

  class MessageController { 
    public function actionHelloWorld() {
      echo 'helloWorld';  
    }
    public function repeat($inputString){
      return $inputString;
    }
  }
  $msg = new MessageController;
?>

I'm not using any PHP framework, i just made the files and classes sounds like it that's all.

and still i get the same error:

PHP Warning:  require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line

Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal error:  require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/php/includes:/opt/lampp/lib/php:/opt/lampp/bin:/opt/lampp/lib/php/PEAR') in /usr/bin/phpunit on line 38

sure, i'm getting demanding here, i've wasted a lot of time and got really frustrated over this, hope you guys dont get bored reading through my questions, i appreciate your help

thanks in advance, Mohamad elbialy

1

1 Answers

7
votes

Finally, i got the answer for the question on how to link the xampp's php and pear to CL (bash shell for ubuntu), type the following in a terminal window:

gedit ~/.bashrc

the file opens and you add the following to the end of file:

export PATH=/opt/lampp/bin:$PATH

and to make sure type the following in the terminal:

echo $PATH

you'll see '/opt/lampp/bin' in the echoed path along with others added by default this is the only way that worked for me after 2-3 days of searching forums, other stackoverflow and superuser questions

to check that the CL is dealing with xampp's php and pear version, type the following:

  1. php -v shows the version of php
  2. pear list shows the version of pear along with pear dependent packages

Now, i've been doing this to make PHPunit work in CL, for 5 days, imagine the frustration, being a newbie to Ubuntu i made alot of sudo and not so sudo commands that missed the whole thing for me, so i decided to make a fresh installation of ubuntu (to delete all those pear, php and phpunit packages that i installed and couldnt track thier path) so starting from a fresh ubuntu 11.10 and xampp 1.7.7, i did the following to make phpunit work:

  1. i made the link for xampp's php and pear with cL (i wrote how above), type the following steps in CL:
  2. sudo /opt/lampp/bin/pear uninstall phpunit (xampp's is 1.2.something, i want to install 3.6.10)
  3. sudo /opt/lampp/bin/pear list (PHPunit is not there, that's a check), the following steps as advised in PHPunit manual1
  4. sudo /opt/lampp/bin/pear config-set auto_discover 1 (opens the download channel or something)
  5. sudo /opt/lampp/bin/pear install pear.phpunit.de/PHPUnit (this installs ver. 3.6.10), now type in CL: sudo /opt/lampp/bin/phpunit --version (this shows the version of 3.6.10, yes you've made it)

i used /opt/lampp/bin/phpunit, to make you see quick results and no, you dont need to include anything in path to work, you already done that, you need to close that terminal and open a new one and type only, phpunit --version, you'll get the same result, it's there, it's all yours

Note:

  1. i used '/opt/lampp/bin/something and then the command', to force my installations through xampp's php and pear, this is not needed (cause you set the environment path), but that's how you get to do things when you spend more than 5 days of search.
  2. i tried working with phpunit 1.2.something of xampp's, but it seems that it's not there for the command line, i dont know why and i dont want to, so if that happens to you and you want ver.1.2.something, find all versions, using the instructions in this link (http://pear.phpunit.de/) and do the same steps to install it, i didnt try the method in that link and if you get stuck you can comment to this answer,