I am using ubuntu 21.04 in that i installed composer by using this command sudo apt-get install composer ,after installing i type composer it's showing following error
HP Fatal error: Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50
please help me to fix this issue
You simply enable mbstring extension it will remove the uncaught error
sudo apt-get install php7.2-mbstring
If you're using PHP 7.4:
sudo apt-get install php7.4-mbstring
Check phpinfo.php for ctype module information. In my case, it wasn't loaded and I didn't see the following:
I activated it in php.ini (location depends on your configuration):
;extension=curl
extension=ctype # uncomment or add this
;extension=ffi
and restart php service. You should see ctype module's block and error should go away.
So I am creating a website for my virtual airline for xplane-11, and I came across this error:
Fatal error: Uncaught Exception: Required GD library is missing in /var/www/html/vam/captcha/simple-php-captcha.php:13 Stack trace: #0 /var/www/html/vam/index.php(15): simple_php_captcha() #1 {main} thrown in /var/www/html/vam/captcha/simple-php-captcha.php on line 13
I have libgd-dev installed on my ubuntu 20.04 and I also have all the extensions uncommented in my php.ini file in the etc/apache2/sites-available folder. I am really frustrated at this point and any help given will be thanked.
From the command line what do you get if you run
php -m | grep -i gd
If it returns
gd
Then the module is included and running in your version of PHP.
Otherwise I would try the following
apt-get install php-gd
Then run the php -m | grep -gd command again after restarting apache
I try to use PHP's password_hash() function with the PASSWORD_ARGON2I algorithm, however, I get the following error message:
Warning: Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' (this will throw an Error in a future
version of PHP) in some-file.php on line 181
Warning: password_hash() expects parameter 2 to be integer, string given in some-file.php on line 192
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'password' cannot be null
in some-file.php:232
Stack trace:
#0 some-file.php(232): PDOStatement->execute()
#1 {main}
thrown in some-file.php on line 232
I followed the official documentation of the function word by word, but I still faced this error.
Then I made some research and I figured out that "PHP should be compiled using –with-password-argon2" (where they refer to this file).
I have no idea how to do this and I could not find any page which would guide me through the steps or provide me more info.
The hashing function works perfectly with PASSWORD_DEFAULT, but that is not what I need at the moment.
I did not know but OSX comes with pre-installed PHP. I had a very early version so I needed to upgrade it in order to make Argon2 algorithm work. When I checked my version by php --version in the command line, I got the following result:
PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
So I followed through this guide but I also had to install Argon2 library (which was not mentioned) and use ./configure —with-password-argon2. So here are the steps which solved my problem based on this guide:
Download the latest PHP source code f.e. from here (I used this .GZ file, but make some research whether there is a newer version or not)
Open the command line
Extract the GZ file and navigate to the extracted source code folder in the command line
You will need Homebrew, install it if you don't have it
Install the dependencies listed in this guide (run brew install libjpeg, brew install pcre, brew install libxml2, etc. in the command line)
Also install Argon2 library (this is not mentioned in the previous guide, you can use this guide)
Now run this in the command line (still same source code folder): ./configure —with-password-argon2
run make test in the command line (time-consuming process, feel free to drink a beer meanwhile)
run sudo make install after
I also restarted my computer, not sure if it was necessary but it worked
When I tried to install Xdebug using
pecl install xdebug
I'm getting the following error. I'm using the latest xampp bitnami distribution on Windows 7 machine.
downloading xdebug-2.2.5.tgz ... Starting to download xdebug-2.2.5.tgz
(255,840 bytes)
.....................................................done: 255,840
bytes 66 source files, building WARNING: php_bin C:\xampp\php\php.exe
appears to have a suffix \php.exe, but config variable php_suffix
does not match ERROR: The DSP xdebug.dsp does not exist.
Do I need to configure anything on php.ini for this?
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:
how to uninstall the php V5.3.6 and it's pear installation?
how to link the CL with the php ver. of xampp?
how to build the next pear installation on the php ver. of xampp?
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:
i wrote this in bash:
gedit ~/.bashrc
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
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
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
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:
php -v shows the version of php
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:
i made the link for xampp's php and pear with cL (i wrote how above),
type the following steps in CL:
sudo /opt/lampp/bin/pear uninstall phpunit (xampp's is 1.2.something, i want to install 3.6.10)
sudo /opt/lampp/bin/pear list (PHPunit is not there, that's a check),
the following steps as advised in PHPunit manual1
sudo /opt/lampp/bin/pear config-set auto_discover 1 (opens the download channel or something)
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:
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.
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,