PHPUnit, Phar and No such file or directory - phpunit

I installed PHPUnit using phar, as described here, http://phpunit.de/manual/3.8/en/installation.html
When I execute phpunit --version it works fine. When I try to execute a test however, it gives me the following error:
PHP Warning: require(PHPUnit/Autoload.php): failed to open stream: No
such file or directory in (blah, blah, blah)...
The phar is installed in /usr/local/bin (as recommended), and I added this path to the include_path in the php.ini for the cli.
Any ideas?

I backed out and installed using PEAR. This got the result I was looking for, but doesn't really answer the question.

Related

Laravel & Valet: Failed to open stream

I'm trying to setup a Laravel project on Valet.
I'm getting this error:
Warning: require(/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/davina/Developer/learn-laravel-graphql/public/index.php on line 24
Fatal error: require(): Failed opening required '/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php' (include_path='.:/usr/local/Cellar/php/7.3.1/share/php/pear') in /Users/davina/Developer/learn-laravel-graphql/public/index.php on line 24
Trying to link either the project root or /public folders results in the above error instead of Laravel's default welcome screen.
How do I resolve this?
Try to navigate to the project folder root and run the command:
composer -i
sudo chmod 755 -R folder_name
Create the .env file, if is fresh application just copy the content of the .env.example file.
inside the project folder again: php artisan key:generate
After those steps all up and running for me :)
Solves the issue for me.
Looks like you have a fresh installation of laravel here...or, you just cloned the repo?
If so, the first thing you should do is to try and install the packages that Laravel uses.
Within those packages is a file called "autoload.php" which your server is looking for here.
Now, to do that, simply navigate within your terminal to the directory of your project and run: composer install.
Wait for it to finish and then, try to continue from there.

What's the expected value for DOTNET_ROOT variable when installing dotnet core from tarballs?

I'm installing dotnet core on Linux ARM64 using tarball as explained here. After installing I followed the suggestion to set DOTNET_ROOT=$PATH:$HOME/dotnet. However global tools fail with A fatal error occurred, the required library libhostfxr.so could not be found.
I fixed by changing the env variable to DOTNET_ROOT=$HOME/dotnet.
Is this a bug in the docs ?
Yes, this appears to be a bug in the documentation. The code which interprets DOTNET_ROOT does not split the string on :. DOTNET_ROOT should be set to an absolute file path which points to the directory containing the dotnet executable. If dotnet is on your PATH already, you can set it like this in bash/zsh.
export DOTNET_ROOT="$(dirname $(which dotnet))"
came across this problem while working on porting .net libraries from Windows to Raspberry PI. On the Raspberry the .net core 3.1 installs in /opt/dotnet, and that's where DOTNET_ROOT ought to point at:
export DOTNET_ROOT="/opt/dotnet"
This should eliminate the "fatal error occurred. The required library libhostfxr.so could not be found." error when attempting to run portable code using the 'dotnet' command on the RPI
I was getting an error trying to execute the dotnet ef from the EF cli global tools install.
Added this to the bottom of my /home/<user>/.bashrc worked for me.
# User specific aliases and functions
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
Then the dotnet ef command worked correctly.
I had to add this to my ~/.zshrc
export DOTNET_ROOT=~/.dotnet
export PATH=$PATH:$DOTNET_ROOT
I found that I had different locations for different sdk/runtime versions. One was installed at "/home/{username}/.dotnet" and the other at "/usr/share/dotnet".
I found a post stating the default DOTNET_ROOT is "/usr/share/dotnet" and errors showed dotnet command was executing this location. I copied all files from "home/{username}/.dotnet" to "/usr/share/dotnet" with rsync.
sudo apt install rsync;
sudo rsync -a /home/{username}/.dotnet/ /usr/share/dotnet

PHPUnit working in IDE, but server says class not found

I am using the Symfony3 plugin in PhpStorm. My PHP Interpreter is 7.0.18. I have PHPUnit 6.3.0 configured in PhpStorm by having the .phar file in the root directory of my project.
Unit test work like a charm inside the IDE however performing any operation on the server (like bin/console server:start) triggers the following messages:
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in
/1tb/programming/PhpstormProjects/binary_search/src/AppBundle/Search/BinarySearchTest.php on line 13
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in
/1tb/programming/PhpstormProjects/binary_search/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Tests/TestCase.php
on line 17
BinarySearchTest.php:
<?php
namespace AppBundle\Search;
use PHPUnit\Framework\TestCase;
class BinarySearchTest extends TestCase
{
}
TestCase.php:
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
class TestCase extends PHPUnitTestCase
{
}
I have read many posts with problems similar but none of them describe the problem the way I do. Then I tried running PHPUnit with phpunit . in the root directory of the folder with this error:
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not
found in
/1tb/programming/PhpstormProjects/binary_search/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
on line 10
It seems whatever I do I just run into more errors. I only just got started with Symfony and read a bit of the documentation but I can't get a grip on this thing, I have been at it for two days. Any suggestions for me?
I have PHPUnit 6.3.0 configured ... by having the .phar file in the root directory of my project
Such a bad idea. PHPUnit should not be installed on your (production?) server.
If this is a local staging server that you're trying to test on, then you need to install the phar in the path.
To globally install the PHAR:
$ wget https://phar.phpunit.de/phpunit-6.2.phar
$ chmod +x phpunit-6.2.phar
$ sudo mv phpunit-6.2.phar /usr/local/bin/phpunit
$ phpunit --version
Also, consider upgrading PHP to the newest version. There are several vulnerabilities in the one you're using. (See: change log for versions between yours and current).
EDIT:
Why are you running bin/console server:start on your server? Also not meant to be on a production server.
My guess here is that it is seeing the phar in your document root and trying to execute it, which is what is causing all the errors.
Installation of PHPUnit via composer worked. It turns out my composer installation went wrong in some way. After composer was successfully installed, I let it handle installing PHPUnit. After that it just worked. Tests work fine in the IDE and the server is responsive again. Thanks LazyOne.

How to rename a Symfony 2 installation folder correctly?

I install Symfony 2.3.0-DEV this way:
composer self-update
git clone https://github.com/symfony/symfony-standard test1
copy .\test1\app\config\parameters.yml .\test1\app\config\parameters.yml.dist
composer install
But, Every time I've had to rename (ie. to "test2") the project folder. My installation breaks and shows errors:
Warning: require_once(C:\xampp\htdocs\symfony-projects\test1\web/../app/bootstrap.php.cache): failed to open stream: No such file or directory in C:\xampp\htdocs\symfony-projects\test1\web\app_dev.php on line 19
Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\symfony-projects\test1\web/../app/bootstrap.php.cache' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\symfony-projects\test1\web\app_dev.php on line 19
I tried, deleting cache folders, deleting the bootstrap.cache.php file, and re-installing/updating vendors, including the autoloader, also with cache:warmup and cache:clear, changing permissions. And still nothing...
Finally solved it ! That's what I've done.
composer self-update
git clone https://github.com/symfony/symfony-standard test1
copy .\test1\app\config\parameters.yml .\test1\app\config\parameters.yml.dist
composer install
Loaded http://localhost/symfony-projects/test1/web/app_dev.php once.
Closed the browser (chrome), stopped xampp (apache/mysql), and the powershell
Deleted /app/cache/* and /app/bootstrap.php.cache file
Closed the IDE, Logoff my user session in Windows 8 (starting feeling paranoid)
Renamed the folder test1 to test2
Executed composer update command to call post-update-cmd scripts to be sure that bootstrap.php.cache is rebuild
Went to http://localhost/symfony-projects/test2/web/app_dev.php
And then works. Probably that issue was due to locked files...
#Touki Thanks, the APC thing was a good insight but not needed it ;)
this topic is quite old but I just had the same problem. The problem was: I installed symfony2 using command:
php composer.phar create-project symfony/framework-standard-edition myProject 2.1.x-dev
but I had the same fatal error. However, my solution was to go myProject directory and run command:
composer update
And that is all, project was rebuilded and file "bootstrap.php.cache" appeard :)
I hope this helps.
Next time, just restart your machine.

Symfony 2.0 bundle installation

So I am a new to doctrine, but I am not able to install a bundle at all. I am following the guide, but the "error" which I am getting is very unusual.
Anyhow, I add this lines into deps file:
[FOSRestBundle]
git=http://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
Then I do:
./bin/vendors install
And I get:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Your project seems to be based on a Standard Edition that includes vendors.
Try to run ./bin/vendors install --reinstall
So on this standard way I am not able to install it at all. Can somebody explain me what is the problem, because to me it looks like, the symfony vendors script doesnt recognize changes in deps file at all.
This happens when you've downloaded the Symfony2 Standard Edition from the website. The vendor install script checks to see if the vendor directories are git repositories, and if not, will throw this error. You can fix the situation in one of two ways:
you can either run the command that it suggests: php bin/vendors install --reinstall
or, you can remove the vendors directory, then run php bin/vendors install, which amounts to about the same thing
No need to install that. Just follow the steps in the url : http://mmoreramerino.github.com/GearmanBundle/installation.html

Resources