preg_match(): Compilation failed: invalid range in character class at offset 20 - laravel

How to solve in laravel an vuejs, when I am trying to refresh the page I got such error message, this is my code from web file :
preg_match(): Compilation failed: invalid range in character class at offset 20
This is my Route:
I ma using laravel 8 php 7.4
Route::get('{path}',"HomeController#index")->where( 'path', '([A-z\d-\/_.]+)?' );
Route::get('{path}',"HomeController#index")->where('path','[-a-z0-9_\s]+');

For php version is 7.3 and above use \- instead of -, so your final code :
Route::get('{path}',"HomeController#index")->where( 'path', '([A\-z\d\-\/_.]+)?' );
Route::get('{path}',"HomeController#index")->where('path','[\-a\-z0\-9_\s]+');

Related

Magento when enabling log through command line getting error

In my Magento application when I try to enable logging in command line using below code
# bin/magento setup:config:set –enable-debug-logging=true
I am getting the error
PHP Fatal error: Declaration of Magenest\SagePay\Helper\Logger::debug($message, array $context = []) must be compatible with Monolog\Logger::debug($message, array $context = []): void in /vendor/magenest/module-sage-pay-basic/Helper/Logger.php on line 49

Laravel/mPDF non-numeric value encountered ErrorException after PHP upgrade to 7.2

I update php7.1 to php7.2.1 (PHP 7.2.1 (cli)) my laravel pdf not generated show below errorr:
(1/1) ErrorException
A non-numeric value encountered
in mpdf.php (line 30648)
at HandleExceptions->handleError(
2,
'A non-numeric value encountered',
'/opt/lampp/htdocs/mysite/vendor/mpdf/mpdf/mpdf.php',
30648,
array(
'size' => 0,
'maxsize' => 190.00155555555551245561218820512294769287109375,
'fontsize' => 3.704166666666667051543981870054267346858978271484375,
'usefontsize' => false)
)
in mpdf.php (line 30648)
Based on the error message, you are using mPDF 6.x which is not compatible with PHP 7.2 (and not entirely with PHP 7.1 for that matter).
You should upgrade to mPDF 7 which is officially supported up to PHP 7.2.

Call to undefined function Illuminate\Support\random_bytes()

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.

Error using PHP_Depend and PHP_PMD

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 ;)

Laravel 4 - Warning: Illegal offset type in isset or empty in \bootstrap\compiled.php

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.

Resources