I receive this error message:
FatalErrorException in Str.php line 243: Call to undefined function Illuminate\Support\random_bytes()
public static function randomBytes($length = 16) {
return random_bytes($length);
}
line 243: return random_bytes($length);
I do not understand what's wrong since a working version Laravel offline that extract online.
It does not work online though. I wonder why?
random_bytes is a PHP 7 function.
I'm assuming that your offline/development stack has PHP 7 installed but not online/production.
Confirm your hosting for PHP 7 installed.
Related
I've installed laravel livewire on a Laravel 8 project, ad when i run the command php artisan make:livewire table the terminal shows this error:
ArgumentCountError
Too few arguments to function Illuminate\Support\Str::finish(), 1 passed in /Applications/MAMP/htdocs/cuoreLaravel/vendor/livewire/livewire/src/helpers.php on line 12 and exactly 2 expected
at vendor/laravel/framework/src/Illuminate/Support/Str.php:235
231▕ * #param string $value
232▕ * #param string $cap
233▕ * #return string
234▕ */
➜ 235▕ public static function finish($value, $cap)
236▕ {
237▕ $quoted = preg_quote($cap, '/');
238▕
239▕ return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
+17 vendor frames
18 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I've followed all the documentation installation steps, but I don't understand what the problem is.
I hope someone can help me :-) thanks
This happened to me after a fresh install of Livewire. Running php artisan optimize fixed it in my case. I have not found the exact reason, but I suspect some of the Livewire config needed to be included in the config cache first.
So either optimize, or clear the cached config completely.
[Solved]
I'm using the repo milon/barcode (v7.0.1) in a Laravel (v7.30.4) application, and yesterday, after updated my server to 7.4.16 (Centos8) , I have got this error:
"Trying to access array offset on value of type bool"
I already checked if the GD PHP extension was enabled (and it is), and I can't find how to solve this.
if (function_exists('imagecreate')) {
// GD library
$imagick = false;
$png = imagecreate($width, $height);
$bgcol = imagecolorallocate($png, 255, 255, 255);
imagecolortransparent($png, $bgcol);
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
Function: getBarcodePNG
Line: 186
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
I think it is a server/php error, but I'm not good in server things :(
Thanks
For who are facing the same issue:
In PHP 7.4, is mandatory to pass all the parameters to the getBarcodePNG function
I'm trying to insert an image in a FPDF fancytable.
I tried to put inside the fancytable function the following :
$this->Cell($w[1],6,$pdf->Image('lettre.jpg',0,0,20,0),'LRB',0,'C',$fill);
but I have (of course) the following error message :
PHP Notice: Undefined variable: pdf in /MyScript.php on line 143
Notice: Undefined variable: pdf in /MyScript.php on line 143
PHP Fatal error: Uncaught Error: Call to a member function Image() on
null in /MyScript.php:143
Stack trace:
0 /MyScript.php(172): PDF->FancyTable(Array, Array)
1 {main} thrown in /MyScript.php on line 143
I understand that I call the pdf function inside the fancytable function (part of the pdf function), so do I have a solution ?
Thanks !
Damn, the answer was in the question : just replaced $pdf by $this and it fixed my problem..
I let the question here just in case somebody have the same error one day ^^
I have a problem using php Depend and PMD. When I use:
pdepend --summary-xml=/home/<mydirectory>/.sonar/pdepend.xml --suffix=php,php3,php4,php5,phtml,inc /home/<mydirectory>
this is the result:
Parsing...
.................................................. 1260
........................PHP Catchable fatal error: Argument 1 passed to PHP_Depend_Parser_UnexpectedTokenException::__construct() must be an instance of PHP_Depend_Token, integer given, called in /usr/share/php/PHP/Depend/Parser.php on line 5444 and defined in /usr/share/php/PHP/Depend/Parser/UnexpectedTokenException.php on line 70
PHP Stack trace:
PHP 1. {main}() /usr/bin/pdepend:0
PHP 2. PHP_Depend_TextUI_Command::main() /usr/bin/pdepend:78
PHP 3. PHP_Depend_TextUI_Command->run() /usr/share/php/PHP/Depend/TextUI/Command.php:679
PHP 4. PHP_Depend_TextUI_Runner->run() /usr/share/php/PHP/Depend/TextUI/Command.php:206
PHP 5. PHP_Depend->analyze() /usr/share/php/PHP/Depend/TextUI/Runner.php:331
PHP 6. PHP_Depend->performParseProcess() /usr/share/php/PHP/Depend.php:306
PHP 7. PHP_Depend_Parser->parse() /usr/share/php/PHP/Depend.php:560
PHP 8. PHP_Depend_Parser->parseOptionalStatement() /usr/share/php/PHP/Depend/Parser.php:370
PHP 9. PHP_Depend_Parser->parseIfStatement() /usr/share/php/PHP/Depend/Parser.php:5474
PHP 10. PHP_Depend_Parser->parseStatementBody() /usr/share/php/PHP/Depend/Parser.php:3195
PHP 11. PHP_Depend_Parser->parseStatement() /usr/share/php/PHP/Depend/Parser.php:2320
PHP 12. PHP_Depend_Parser_UnexpectedTokenException->__construct() /usr/share/php/PHP/Depend/Parser.php:5444
The same happens with:
phpmd /home/<mydirectory> xml /home/<mydirectory>/Sonar_Way_php.xml
PHP Catchable fatal error: Argument 1 passed to PHP_Depend_Parser_UnexpectedTokenException::__construct() must be an instance of PHP_Depend_Token, integer given, called in /usr/share/php/PHP/Depend/Parser.php on line 5444 and defined in /usr/share/php/PHP/Depend/Parser/UnexpectedTokenException.php on line 70
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpmd:0
PHP 2. PHP_PMD_TextUI_Command::main() /usr/bin/phpmd:48
PHP 3. PHP_PMD_TextUI_Command->run() /usr/share/php/PHP/PMD/TextUI/Command.php:151
PHP 4. PHP_PMD->processFiles() /usr/share/php/PHP/PMD/TextUI/Command.php:129
PHP 5. PHP_PMD_Parser->parse() /usr/share/php/PHP/PMD.php:203
PHP 6. PHP_Depend->analyze() /usr/share/php/PHP/PMD/Parser.php:128
PHP 7. PHP_Depend->performParseProcess() /usr/share/php/PHP/Depend.php:306
PHP 8. PHP_Depend_Parser->parse() /usr/share/php/PHP/Depend.php:560
PHP 9. PHP_Depend_Parser->parseOptionalStatement() /usr/share/php/PHP/Depend/Parser.php:370
PHP 10. PHP_Depend_Parser->parseIfStatement() /usr/share/php/PHP/Depend/Parser.php:5474
PHP 11. PHP_Depend_Parser->parseStatementBody() /usr/share/php/PHP/Depend/Parser.php:3195
PHP 12. PHP_Depend_Parser->parseStatement() /usr/share/php/PHP/Depend/Parser.php:2320
PHP 13. PHP_Depend_Parser_UnexpectedTokenException->__construct() /usr/share/php/PHP/Depend/Parser.php:5444
¿Any sugestion? Thanks.
It's a bug of pdepend and pmd. In /usr/share/php/PHP/Depend/parser.php I changed:
private function parseStatement()
{
if (null === ($stmt = $this->parseOptionalStatement())) {
throw new PHP_Depend_Parser_UnexpectedTokenException(
$this->tokenizer->next(),
$this->sourceFile->getFileName()
);
}
return $stmt;
}
for this:
private function parseStatement()
{
if (null === ($stmt = $this->parseOptionalStatement())) {
throw new PHP_Depend_Parser_UnexpectedTokenException(
new PHP_Depend_Token,
$this->sourceFile->getFileName()
);
}
return $stmt;
}
I obtain only warnings and the process continue:
PHP Warning: Missing argument 1 for PHP_Depend_Token::__construct(), called in /usr/share/php/PHP/Depend/Parser.php on line 5442 and defined in /usr/share/php/PHP/Depend/Token.php on line 121
We can wait next upgrade ;)
I'm having a hard time installing Laravel 4 on Windows 8 + Xampp.
Here's the setup:
- Xampp 1.8.1
- Composer is installed globally
I install Laravel with the usual "composer create-project laravel/laravel projectname". It installs fine.
But when I navigate to the public folder of the framework, I get dozens of Warning: Illegal offset type in isset or empty in \bootstrap\compiled.php errors.
On lines : 439, 221, 137, 154. The 4 errors are repeated indefinitely until the request times out.
Troubleshooting done so far:
- Tried on 2 seperate machines with the same setup.
- Re-ran Composer update.
- Instead of using create-project, I downloaded the framework and ran Composer install.
- Tried to setup up virtual hosts instead of accessing localhost/projectname/public.
- Searched online for 2 hours. Read every Laravel 4 install tutorial.
Any clues on what I might be doing wrong?
Thanks
-- EDIT --
Here are the lines causing the problem inside of compiled.php
Line 137 section :
$abstract = $this->getAlias($abstract);
if (isset($this->instances[$abstract])) {
return $this->instances[$abstract];
}
Line 154 section :
protected function getConcrete($abstract)
{
if (!isset($this->bindings[$abstract])) {
return $abstract;
} else {
return $this->bindings[$abstract]['concrete'];
}
}
Line 221 section :
protected function getAlias($abstract)
{
return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract;
}
Line 439 section :
public function make($abstract, $parameters = array())
{
if (isset($this->deferredServices[$abstract])) {
$this->loadDeferredProvider($abstract);
}
return parent::make($abstract, $parameters);
}
-- NEW FIND --
Using Wampserver works, instead of using Xampp.
Encountered the same error when using Xampp. I fixed it by disabling the eAccelerator extension in php.ini. Try commenting out the following line: zend_extension = "path\to\xampp\php\ext\php_eaccelerator_ts.dll" in your php.ini file.