PHP7 built-in hash() function undefined - hash

I'm running PHP Version 7.0.5 and trying to use the hash function.
echo hash('sha256', 'The quick brown fox jumped over the lazy dog.');
The script returns the following error message:
Fatal error: Uncaught Error: Call to undefined function hash()
The PHP docs indicate that the function should be included with PHP 7:
http://php.net/manual/en/function.hash.php
(PHP 5 >= 5.1.2, PHP 7, PECL hash >= 1.1)
What am I missing? How do I add the standard hash functions to my PHP 7 environment?

I had the same issue running PHP 7.2.34. Installing php7-mod-hash fixed it for me:
opkg update
opkg install php7-mod-hash

Related

Net::SSH2::Simple failed after update to Windows10

there
On Net::SSH2::Simple,
It has been no longer connected by ssh after update Windows7 to Windows10.
With following error.
Net::SSH2::net_ss_timeout: invalid object Net::SSH2::Simple=SCALAR(0x3f5c218) at C:/Strawberry/perl/vendor/lib/Net/SSH2.pm line 111.
at C:/Strawberry/perl/vendor/lib/Net/SSH2.pm line 111.
Net::SSH2::connect(Net::SSH2::Simple=SCALAR(0x3f5c218), "xxxx.com", 22) called at C:/tool/eclipse_classic/workspace/test/work14.pl line 98
(in cleanup) Net::SSH2::net_ss_DESTROY: invalid object Net::SSH2::Simple=SCALAR(0x3f5c218) at C:/tool/eclipse_oxygen/eclipse/workspace/.metadata/.plugins/org.epic.debug/perl5db.pl line 4211.
My code are
use Net::SSH2::Simple;
$ssh2 = Net::SSH2::Simple->new();
$ssh2->connect( 'xxxx.com', 22 ) ;
$ssh2->auth_password( 'username', 'passwd' );
Error comes up at "$ssh2->connect" line.
But
This code works fine by using Net::SSH2.
Only Net::SSH2::Simple doesn't work.
To xxxx.com connection is fine. and no username,password mistakes found.
How can I fix that.
Windows10 64bit
Strawberry Perl 5.30.1.1 (64bit)
Eclipse Oxygen
EPIC 0.77
Thanks
Net::SSH2::Simple 0.01 was released Dec 13 2009. At that time Net::SSH2 was at 0.28 (2009-10-24), it is now at 0.70 (2019-3-17).
I got Net::SSH2::Simple to work on Windows10 64bit / Strawberry Perl 5.30.0.1 (64bit) by installing the earlier version 0.58 (2015-12-20) of Net::SSH2 using
cpan install SALVA/Net-SSH2-0.58.tar.gz
Version 0.59_20 (2016-05-11) gives the 'net_ss_timeout: invalid object' error . The change log for version 0.59_01 has this warning
** WARNING: this release includes lots of changes, some
visible, most internal. Regressions are expected. Also,
it introduces some minor backward incompatible changes -
but in those cases, the old behavior was broken or insane
anyway.

Lumen Dingo php artisan command error

I have installed Lumen, Dingo to test the JWT integration.
On terminal when I try to run unit test case using php artisan command it throws following error
PHP Fatal error: Call to undefined function Dingo\Api\Provider\config_path() in /usr/local/var/www/vhosts/storm/vendor/dingo/api/src/Provider/LaravelServiceProvider.php on line 26
PHP Stack trace:
PHP 1. {main}() /usr/local/var/www/vhosts/xxx/artisan:0
PHP 2. require() /usr/local/var/www/vhosts/xxx/artisan:18
PHP 3. Laravel\Lumen\Application->register() /usr/local/var/www/vhosts/storm/bootstrap/app.php:84
PHP 4. Illuminate\Container\Container->call() /usr/local/var/www/vhosts/storm/vendor/laravel/lumen-framework/src/Application.php:176
PHP 5. Illuminate\Container\BoundMethod::call() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/Container.php:531
PHP 6. Illuminate\Container\BoundMethod::callBoundMethod() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:31
PHP 7. Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:87
PHP 8. call_user_func_array:{/usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30}() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30
PHP 9. Dingo\Api\Provider\LaravelServiceProvider->boot() /usr/local/var/www/vhosts/storm/vendor/illuminate/container/BoundMethod.php:30
My composer.json:
"laravel/lumen-framework": "5.4.*",
"vlucas/phpdotenv": "~2.2",
"dingo/api": "1.0.*#dev",
"guzzlehttp/guzzle": "^6.2",
"lukasoppermann/http-status": "^2.0"
Any php artisan command is throwing above error.
I can only suspect that you registered the LaravelServiceProvider instead of using the LumenServiceProvider.
As Lumen does not have the helper function config_path() you're getting this error.
So according to the install instructions you should add
$app->register(Dingo\Api\Provider\LumenServiceProvider::class);
to your bootstrap/app.php.

Installing cpan module getting Could not make error

I want to install cpan module called Coro for Perl, after typing
cpan Coro
I get error something like Could not make: Unknown error
Here is full log from console: http://pastebin.com/NpXbG2eN
I do not know what is wrong with this.
I found some errors during install:
error: lvalue required as left operand of assignment fatal error:
db.h: No such file or directory
This is relevant:
*** It seems you are running perl version 5.022001, likely the "official" or
*** "standard" version. While there is nothing wrong with doing that,
*** standard perl versions 5.022 and up are not supported by Coro.
The error you are getting:
State.xs: In function ‘coro_derive_padlist’:
State.xs:581:29: error: lvalue required as left operand of assignment
PadlistNAMES (newpadlist) = padnames;
Coro relies on Perl internals that changed.

Perl CGI::Validate install / usage fails

I have installed the Perl CGI::Validate module via cpan. I had to force the install due to an error in installation - I get the same error when I try to use the module at all (unsurprisingly).
Can't use an undefined value as an ARRAY reference at /usr/local/share/perl5/CGI/Validate.pm" line 216., referer: ...
Is this a bug with the Validate module? For reference - line 216 (and the following few lines) of Validate.pm:
unless (scalar #{ $form{$field} } or $fields{$field}{optional}) {
$Blank{$field} = qq(Required field "$field" contains no data);
next;
}
Anything obvious?
the build work only in this enviroments :
Windows (32bit) Perl 5.10
Linux (32bit) Perl 5.10
on other Enviroments the build fail , eg win64bit linux64bit MacOsx with Perl Ver 5.8 , 5.12 . 5.14, 5.16 , 5.18 , 5.20 , 5.22
this may be due to the droped support to the CGI package
look at this page for more detail
http://code.activestate.com/ppm/CGI-Validate/

Perl Cross Compilation: MAKE

I've been trying to Cross Compile Perl-5.14.2 for NetBSD target from Linux machine.
Configure script successfully invoked with following options,
./Configure -des -Dusecrosscompile
-Dtargetarch=netbsd
-Dosvers=3.0.0
-Dtargethost=10.184.22.48
-Dtargetuser=username
-Dusrinc=.../sb1-mips/usr/include
-Dlibpth=.../xc-sb1-mips/netbsd/Lib/lib
-Dcc=.../mips64-netbsdelf-gcc
Once after Configured, make wasn't successful.
It breaks at different places right from creating miniperlmain.o file.
For example following error occurred while generating gv.o file:
gv.c: In function `Perl_try_amagic_un':
gv.c:2018: error: void value not ignored as it ought to be
gv.c:2029: error: void value not ignored as it ought to be
gv.c:2029: warning: cast from pointer to integer of different size
gv.c: In function `Perl_try_amagic_bin':
gv.c:2061: error: void value not ignored as it ought to be
gv.c:2063: error: void value not ignored as it ought to be
make: *** [gv.o] Error 1
Now to get rid of these errors I've passed two flags namely -DPERL_IMPLICIT_CONTEXT and -DPERL_GCC_BRACE_GROUPS_FORBIDDEN to C Compiler CCFLAGS which solved the problem.
Since it is a custom build, want to know about all of the CCFLAGS that have to be passed in order to achieve a successful build?
What does each flag mean?
Is their any documentation available?
Use vagrant. It has some OpenBSD and FreeBSD images. Hopefuly those will be compatible with NetBSD.
You can get a build environment very fast with that. Then you can transfer and build your code happily :)