Lumen Dingo php artisan command error - lumen

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.

Related

PHP7 built-in hash() function undefined

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

php bin/magento setup:upgrade gives error (localhost ubuntu 16.04)

PHP bin/Magento module:status
I am making magneto simple custom module but give me below error.
user#user:/opt/lampp/htdocs/magento2$ php bin/magento module:status
PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /opt/lampp/htdocs/magento2/vendor/magento/framework/Config/Dom.php:364
Stack trace:
#0 /opt/lampp/htdocs/magento2/vendor/magento/framework/Config/Dom.php(109): Magento\Framework\Config\Dom->_initDom('<?xml version="...')
#1 /opt/lampp/htdocs/magento2/vendor/magento/framework/ObjectManager/Config/Reader/Dom.php(70): Magento\Framework\Config\Dom->__construct('<?xml version="...', Object(Magento\Framework\App\Arguments\ValidationState), Array, 'xsi:type', NULL)
#2 /opt/lampp/htdocs/magento2/vendor/magento/framework/Config/Reader/Filesystem.php(146): Magento\Framework\ObjectManager\Config\Reader\Dom->_createConfigMerger('Magento\\Framewo...', '<?xml version="...')
#3 /opt/lampp/htdocs/magento2/vendor/magento/framework/Config/Reader/Filesystem.php(127): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator))
#4 /opt/lampp/htdocs/magento2/vendor/magento/framework/App/ObjectManagerFactory.php(269): Magento\Framework\Config in /opt/lampp/htdocs/magento2/vendor/magento/framework/Config/Dom.php on line 364
i even installed dom by using below command
restarted the apache2 again but same error /
usser#user:/opt/lampp/htdocs/magento2$ sudo apt-get install php5.6-dom
Hey will you please try setup:upgrade command after removing generated files using following command..
rm -rf var/di var/generation var/cache var/page_cache var/view_preprocessed
The problem might not of the Dom may be.

CasperJS with SlimerJS under linux

I'm trying to execute a CasperJS script using SlimerJS (My tests must check html5 video which is not available using PhantomJS).
Using CasperJS on top of PhantomJS, all of my scripts work just fine, however with CasperJS on top of SlimerJS, I cannot execute any of them. instead, I just always get the following error message:
[alex#webdev-srv test]$ xvfb-run casperjs --engine=slimerjs test2.js
Script Error: Cannot find package.json at /home/alex/headless/phantomjs/test/package.json
Stack:
-> : 0
1474876419994 addons.repository WARN cacheEnabled: Couldn't get pref: extensions.getAddons.cache.enabled
I'm using CentOS 7 as VPS (No GUI), with Firefox being installed, and XVFB too.
How can I make it work? Or is there any solution for this?

PHP Fatal error: Class 'Phar' not found in

When I deploy my commits via Git to the server, it runs a git hook that has the line
test -f composer.phar && ./composer.phar self-update || curl -s http://getcomposer.org/installer | php;
That generates the error:
PHP Fatal error: Class 'Phar' not found in .../composer.phar on line 23
This is line 23 from composer.phar:
Phar::mapPhar('composer.phar');
I did search other questions with the same problem and checked these things:
git hook's script already has permission to be executed
I can execute ./composer.phar without error when logged in server and inside the same folder as set in the git hook's script
PHP modules has Phar enabled, checked via php -m
There is no extension=phar.so in php.ini, but I dont think it has to be because it's already enabled
PHP version: PHP 5.5.3 (cli)
What else could be causing this?

trouble installing MozRepl

I've been trying to install WWW::Mechanize::Firefox through CPAN and I am having trouble installing the dependency MozRepl. The installation goes through but the tests all fail, and when I force install it and run my perl script, I run into an error
Failed to connect to , at /Library/Perl/5.12/MozRepl/RemoteObject.pm line 467.
SO I uninstalled MozRepl and looked at the tests I get the following errors in the log:
# Failed test at t/10-plugin-repl-enter.t line 11.
Can't locate object method "repl_enter" via package "MozRepl" at t/10-plugin-repl-enter.t line 12.
...
# Failed test at t/20-plugin-json.t line 16.
Can't locate object method "json" via package "MozRepl" at t/20-plugin-json.t line 17.
# Failed test at t/19-plugin-repl-util-doc_for.t line 14.
Can't locate object method "repl_doc_for" via package "MozRepl" at t/19-plugin-repl-util-doc_for.t line 16.
# Failed test at t/18-plugin-repl-util-help_url_for.t line 14.
Can't locate object method "repl_help_url" via package "MozRepl" at t/18-plugin-repl-util-help_url_for.t line 16.
etc..
I am running on Mac OSX 10.8.4, 4 GB Ram 2.5 Ghz, Perl version 5.12. Does anybody have any idea what is causing these errors?
UPDATE:
i reinstalled mozrepl, and now I get this error when i run my script:
Failed to connect to , problem connecting to "localhost", port 4242: Connection refused at /Users/thui/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/MozRepl/Client.pm line 144
This works for me with perl 5.10 or later, latest Firefox (26 as of writing) and Mozrepl from github.
At command propmpt:
(1) Download MozRepl and build the XPI file (Firefox extension):
git clone git://github.com/bard/mozrepl
cd mozrepl
zip -r ../mozrepl.zip *
cd ..
mv mozrepl.zip mozrepl.xpi
(2) Install the extension in Firefox via about:addons [Install from file].
In Firefox:
(3) Menu->Tools->Mozrepl->Activate On Startup
(4) Menu->Tools->Mozrepl->Start
At command propmpt:
(5) which firefox
Make sure the firefox executable (or your OS's wrapper script) is in $PATH - you should get some output!
(6) cpanm WWW::Mechanize::Firefox
(7) Test it!
At this point, if CPANminus reports no errors then WWW::Mechanize::Firefox should be working. The first example from the synopsis is a good test:
#!/usr/bin/perl
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');
That assumes MozRepl is listening on port 4242 (check in Menu->Tools->Mozrepl->Change Port). You can also change the port from the perl side; see options for ->new().
(8) cpanm HTML::Display::Common
I found that bcat.pl from the examples required this module, but it wasn't installed as a dependency.