$file = $request->file('excel');
$reader = Excel::load($file->getRealPath())->get();
The following error appears:
Call to undefined method Maatwebsite\Excel\Facades\Excel::load()
I am using Maatwebsite 3 in laravel 5.7
The load method has been removed as quoted in the las post, however it has been already implemented in 3.1 version.
Excel::load() is removed and replaced by Excel::import($yourImport)
Checkout this link
Personally, I ended it up using Excel::toColletion($file) though.
^3.0 versions of maatwebsite/excel does not support loads.
Delete the config/excel.php file first .
Downgrade the maatwebsite/excel version by changing your composer.json
"maatwebsite/excel": "^3.1", to "maatwebsite/excel": "~2.1.0"
perform composer update.
And if you get an error "Undefined class constant 'XLSX' in 2.1 version",this is what you have to do .
delete the config/excel.php before downgrading
then perform composer update.
The load method has been removed in version 3.0 (may be re-added in 3.1). Please refer the upgrade guide
ALL Laravel Excel 2.* methods are deprecated and will not be able to
use in 3.0 .
Excel::load() is removed and will not be re-added until 3.1
Excel::create() is removed and replaced by Excel::download/Excel::store($yourExport)
v3.0 provides no convenience methods for styling, you are encouraged to use PhpSpreadsheets native methods.
Related
composer install error on carbon 1 is deprecated
SO, how can i run my vagrant with laravel 5.1 with carbon 1 and I have try find from stackoverflow and other site but no helps comes up .
every thing is done but shows carbon 1 is deprecated
As per https://carbon.nesbot.com/
You can install Carbon 2:
{
"require": {
"nesbot/carbon": "2.64.0 as 1.39.0"
"kylekatarnls/laravel-carbon-2": "^1.0.0"
}
}
But such an old stack will gives you so much trouble. Laravel 5.1 and PHP 7.1 are both in end of life (no longer maintained). You should upgrade the whole stack. At this point having Carbon 1 would make little difference. If you're fine with having old stuff, no longer matching their documentation, then you can ignore deprecation notices.
NB: Local server PHP Version 8.1.4, laravel project inside composer.json file have "php": "^7.2.5", version & "laravel/framework": "^7.0"
PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
error displaying below like this :
That's a php version issue. Upgrade laravel or downgrade PHP. This article covers how to downgrade the PHP version so it matches the Laravel Version.
https://bytexd.com/fix-laravel-return-type-of-illuminatesupportcollectionoffsetexistskey/
in your composer.json update line
"php": "^7.3",
to
"php": "^7.3|^8.1",
and run composer update
You would need to upgrade your Laravel Framework version to at least version 8 and it's dependencies using composer.
Reference: https://laravel.com/docs/8.x/releases
Or if you want to postpone it, you would need to add #[\ReturnTypeWillChange] before declaring every function that throws the error. This is highly not advisable.
P.S. If you updated your PHP version you would have to change the PHP version in composer to the one used, in your case it should be "php": "^8.1.4"
In my case, using a mac, turns out my php version was 8.1 which somehow is not compatible with laravel version 7. Tho most of these answers are correct, but they did not fix my issues. I followed these steps (if brew is installed):
brew unlink php#8.1
brew link php#8.0 or lower
Reference How can I easily switch between PHP versions on Mac OSX?
run "composer update" on your project directory and it will work .
I have installed the s3 flysystem package by running the following composer command in my Laravel 8 project
composer require --with-all-dependencies league/flysystem-aws-s3-v3 "^1.0"
and tried to store a file from the request as
$imageName = $request->file('file')->store('uploads');
I got the following error
League\Flysystem\AwsS3v3\AwsS3Adapter::__construct(): Argument #1
($client) must be of type Aws\S3Client, Aws\S3\S3Client given, called
in
D:\Projects\Rescale\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemManager.php
on line 229
So it seems ThePHPLeague Flysystem major version got updated (to v2) thus breaking a lot of stuff since latest Laravel depends on "^1.1" (see: https://github.com/laravel/framework/blob/8.x/composer.json#L27).
I've had this error, so my workaround is to use a specific version instead.
Go to composer.json and use latest v1 (see: https://github.com/thephpleague/flysystem-aws-s3-v3/tags).
- "league/flysystem-aws-s3-v3": "^1.0",
+ "league/flysystem-aws-s3-v3": "1.0.29",
Run composer update and let composer update your dependencies.
try this to upload an image on AWS
$path = Storage::disk('s3')->put('uploads', $request->file('file'));
try this
composer require --with-all-dependencies league/flysystem-aws-s3-v3 "~1.0"
I got same error in Laravel version 8
open composer.json and change inside version to "league/flysystem-aws-s3-v3": "^1.0"
run composer update
after updating my mac to php 8 laravel app stopped working, this is the error I'm getting:
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
I've tried to fix the issue by investigating the code with no luck
THE SOLUTION
As explained here latest version of laravel 6, 7 and 8 has made changes required for php 8. all you have to do is:
1- add php 8 to your composer.json (I've kept v7.4 just in case production server does not support php 8 yet)
"php": "^7.4|^8.0",
2- to run composer update to update your laravel to the latest version
composer update
3- make sure update the following libraries since they exist in all laravel applications
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3
4- check for any other library which needs to be updated, contribute if they haven't supported php 8. but you should be good to go with most of the libraries since they have active contributors.
EXPLAINING THE PROBLEM
as described here
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's
ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is
deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType() is the recommended way to replace the
deprecated methods. This method is available in PHP 7.0 and later.
Check your php version in your virtual machine(xampp or server).
php --version
Is that version PHP 8 ? Am I right? That's the cause of the problem:
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType()
Downgrade your php version to 7.4 and your Laravel app works like a charm!
I had similar issue. But I had already run brew update and brew cleanup before I noticed the issue. What I did:
I noticed this error from brew cleanup:
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite heroku-node
I ran the commands:
brew link --overwrite composer
composer upgrade
composer update
That's what worked for me
If you're using valet you should do the followings:
Downgrade from php8+ to php7.4 valet isolate php#7.4
Then run composer update using valet valet composer update
I've installed PHPSpreadsheet and JpGraph via composer on a Windows machine. I'm using the following code but am getting the error "Class 'Graph' not found". Is there another way I need to be including JpGraph?
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph;
$graph = new Graph(400,300);
jpgraph/jpgraph package is outdated and abandoned.
Since version 1.25 PHPOffice/PhpSpreadsheet supports mitoteam/jpgraph package which is actual and has php 8.2
After installing both packages by composer you need to setup PhpSpreadsheet to use mitoteam/jpgraph as renderer:
\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer(
\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class
);
Additional details:
https://github.com/PHPOffice/PhpSpreadsheet#chart-export
https://packagist.org/packages/mitoteam/jpgraph