Click here to Skip to main content
12,623,511 members (31,474 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.9K views
1 bookmarked
Posted

PHPUnit - Migrate from PEAR Install to PHAR (Windows & Linux)

, 13 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
PHPUnit - Migrate from PEAR Install to PHAR (Windows & Linux)

Introduction

You have installed PHPUnit with PEAR, but the installation method is migrating and you keep getting the error message:

You have installed PHPUnit via PEAR. This installation method is no longer supported and http://pear.phpunit.de/ will be shut down no later than December, 31 2014.

Please read http://phpunit.de/manual/current/en/installation.html and learn how to use PHPUnit from a PHAR or install it via Composer.

It lets you know that you haven't installed it the right way, but now how do you correct the problem and remove the annoying error message?

First Remove It (Windows & Linux)

pear uninstall phpunit/PHPUnit

Get and Install PHPUnit using the phar, Linux (or Amazon EC2) Version

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit

#and in my case, the phpunit executable also needed to be placed here:

cp /usr/local/bin/phpunit /usr/bin/phpunit

Get and Install PHPUnit using the phar, Windows Version

Download the .phar file to somewhere you can run it with PHP.

  1. Open this address in a browser and save to your disk:

    https://phar.phpunit.de/phpunit.phar

  2. Open the command line and go to the directory (cd {savepath}) you have saved the file in.
  3. Execute tests with:
    php phpunit.phar testfile.php
  4. Copy phpunit.phar to overwrite your existing phpunit file (replace c:\php\phpunit with your installed location). Back up the original phpunit file just in case.
    copy c:\php\phpunit c:\php\phpunit.bak
        copy phpunit.phar c:\php\phpunit

NOTE

If you are getting the error below when running your tests:

Failed opening required 'PHPUnit/Autoload.php'
You may need to remove or comment out the Autoload include line. This file has already been included in the .phar PHP Archive.

//require_once 'PHPUnit/Autoload.php';

Now, use this testing framework to check your code and help you feel confident when deploying your applications.

There are a great number of resources on the official PHPUnit page that you should check out if you want to learn more about PHPUnit and how to use it to your advantage - PHPUnit Presentations.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Right Handed Monkey
Chief Technology Officer WorxForUs
United States United States
I am a programmer who posts rambling on about java, Android, PHP, or whatever I am motivated to type on my charcoal colored Kinesis Freestyle2 keyboard. Please send +1's, shared links, warm thoughts of encouragement, or emasculating flames of internet fury to my blog. Thanks for reading!

righthandedmonkey.com

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161128.1 | Last Updated 13 Jun 2014
Article Copyright 2014 by Right Handed Monkey
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid