

Class 'App\Http\Controllers\ZipArchive' not found in Laravel
source link: https://www.laravelcode.com/post/class-app-http-controllers-ziparchive-not-found-in-laravel
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Class 'App\Http\Controllers\ZipArchive' not found in Laravel
While working on Zip file in your Laravel application, you might need to use PHP in-built class ZipArchive. When you use class in your controller file, you might get error "Class 'App\Http\Controllers\ZipArchive' not found"
.
To use ZipArchive class in PHP, you need to have installed and enabled zip extension which is which uses libzip. You can simply install zip extension with your enabled PHP version.
PHP7.4
sudo apt-get install php7.4-zip
PHP8.0
sudo apt-get install php8.0-zip
And don't forget to restart apache server to implement changes.
sudo service apache2 restart
Now refresh the page and error should have gone. If you still get the error, make use you have use class above else Laravel will try to find class in your Controllers directory.
<?php
namespace App\Http\Controllers;
use ZipArchive;
/**
* Show the application homepage.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
...
$zip = new ZipArchive;
...
}
I hope this will help you.

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Recommend
-
38
README.md
-
7
Inheritance and Abstract Class Pattern for Ruby on Rails Controllers Updated Jan 7, 2020 4 minute read
-
12
Keep controllers clean by using form requests in Laravel Original – ...
-
9
HTTP 404, freedom not found August 23, 2021 Dietrich Ayala While internet...
-
2
Laravel - Controllers without routing advertisements I am newbie to laravel. I created new controller - book. This is my code -
-
15
HTTP Status 404 – Not FoundHTTP Status 404 – Not FoundType Status ReportMessage JSP file [/popular_api.jsp] not foundDescription The origin server did not find a current representation for the...
-
5
Invokable Controllers Example in Laravel 7 7723 views 1 year ago Laravel Hello Artisan In this following tut...
-
11
How To Create ZIP File In Laravel Using ZipArchive 369596 views 4 years ago Laravel Hello, Everyone in this tutoria...
-
12
Controllers and Middleware in Express App Read Previous: Routing in node js express app
-
18
Shardul Joshi Jul 01, 2022 at 05:47 AM Service Cannot be reached ( HTTP 400 - session not found 564 Views...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK