I have this laravel api hosted on a sharefd hosting siteground, i made some changes like changing the public folder to public html and update the storage filing so i can be able to run the laravel storage link commande bu i encountred this error while trying to access my temporary domain
FULL ERROR NAME
CarbonCarbon::setLastErrors(): Argument #1 ($lastErrors) must be of type array, bool given, called in /home/customer/www/bassemb5.sg-host.com/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php on line 98
and this is my index.php
looks like
<?php
use IlluminateContractsHttpKernel;
use IlluminateHttpRequest;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->bind('path.public', fn() => base_path('/public_html'));
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);
and this is the line i added and it was working perfectly
$app->bind('path.public', fn() => base_path('/public_html'));
6
Answers
Also managing my old site on Siteground, customer contacted told me about 500 error.
app_debug
we had the same error.It does not happen on localhost because I have PHP 8.1 installed.
If you’re using PHP 8.2 and this problem appears, you need to update your composer.lock to the latest carbon version
or just pull back your PHP version to 8.1
UPDATE: this error came from Siteground Auto Updating your PHP VERSION to 8.2
I have mine forced to PHP 8.1 yet they still Auto Managed it and upgraded the PHP Version to 8.2 without any notifications or advise
We had exactly the same error (same file and line) than OP.
In our research it looks like it got broken after 2.57 (working), for us 2.58 was already failing and broke our pipeline, failing in the "composer install" phase with exactly same error.
As @tomexsans mentions it seems to be fixed in 2.62.1+. We upgraded to the latest available version today (2.64) and worked fine, getting the issue fixed.
—
TL;DR
should do the trick.
We used carbon in combination with aporat – store receipt validator.
Unfortunately we couldn’t update the nesbot using composer, due hardlocked versions and nesbot being a dependency of another library.
Luckily when comparing the libraries Creator file we saw the hotfix in the latest version, by that time being:
https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Traits/Creator.php
We ended up fixing it with only updating that specific file, since only the setLastErrors() function was updated there.
I truly hope it helps someone.
Hi Also managing my old site.
You need to update your composer by using
And all work fine
If you can not change your PHP version to 8.1, you can update this line
File Path
./vendor/nesbot/carbon/src/Carbon/Traits/Creator.php
Line No:
928
Old Line
private static function setLastErrors(array $lastErrors)
New Line
private static function setLastErrors($lastErrors)
I had this issue a few days again
just type
composer update
on your terminal that will solve the issue.Give this a vote afterward.