laravel-zip
laravel-zip copied to clipboard
Problem generating IDE helpers
Hello Zippers.
I try use this library in my project but when I try make a IDE Helpers, I get error.
> if [ $COMPOSER_DEV_MODE -eq 1 ]; then php artisan ide-helper:generate; fi
TypeError
Cannot assign Illuminate\Foundation\Application to property ZanySoft\Zip\Zip::$zip_file of type ?string
at vendor/zanysoft/laravel-zip/src/Zip.php:114
110▕ if (empty($zip_file)) {
111▕ throw new \Exception(self::getStatus(ZipArchive::ER_NOENT));
112▕ }
113▕
➜ 114▕ $this->zip_file = $zip_file;
115▕ }
116▕
117▕ /**
118▕ * Open a zip archive
+28 vendor frames
29 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
How is possible fix this problem.
Thanks very much for this library
Yoinier.
The content of $zip_file is:
^ Illuminate\Foundation\Application^ {#3
#resolved: array:103 [
"events" => true
"App\Console\Kernel" => true
"Illuminate\Contracts\Console\Kernel" => true
"Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables" => true
"Illuminate\Foundation\Bootstrap\LoadConfiguration" => true
"Illuminate\Foundation\Bootstrap\HandleExceptions" => true
"env" => true
"Illuminate\Foundation\Bootstrap\RegisterFacades" => true
"Illuminate\Foundation\PackageManifest" => true
"Illuminate\Foundation\Bootstrap\SetRequestForConsole" => true
"Illuminate\Foundation\Bootstrap\RegisterProviders" => true
"Livewire\LivewireManager" => true
"App\Exceptions\Handler" => true
"Illuminate\Contracts\Debug\ExceptionHandler" => true
"Spatie\Ignition\Contracts\ConfigManager" => true
...
then??
Yoinier.
Kindly use version 2.0.x if you are using PHP 7.4 or 8.x
Version 2.0.2 with php 8.1:
> if [ $COMPOSER_DEV_MODE -eq 1 ]; then php artisan ide-helper:generate; fi
TypeError
Cannot assign Illuminate\Foundation\Application to property ZanySoft\Zip\Zip::$zip_file of type ?string
at vendor/zanysoft/laravel-zip/src/Zip.php:114
110▕ if (empty($zip_file)) {
111▕ throw new \Exception(self::getStatus(ZipArchive::ER_NOENT));
112▕ }
113▕
➜ 114▕ $this->zip_file = $zip_file;
115▕ }
116▕
117▕ /**
118▕ * Open a zip archive
Then, I comment that:
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//$this->registerCpanelService();
/*if ($this->app->runningInConsole()) {
$this->registerResources();
}*/
}
and cuasi-work
> if [ $COMPOSER_DEV_MODE -eq 1 ]; then php artisan ide-helper:generate; fi
Exception: Target class [zip] does not exist.
Skipping \ZanySoft\Zip\ZipFacade.
Exception: Target class [zip] does not exist.
Skipping \ZanySoft\Zip\ZipFacade.
A new helper file was written to _ide_helper.php
Im are using Laravel v9.26.1 (PHP v8.1.9) and Zip Library 2.0.2
Thanks
Also experiencing this issue with PHP 8.1.9, Laravel 9.26.1 and version 2.0.2 of this package. Not limited to ide-helper generation, same line as OP.
hi @zanysoft, it´s clear, that this is wrong 😏 - so please switch this issue to OPEN again.
here you assign Illuminate\Foundation\Application
https://github.com/zanysoft/laravel-zip/blob/9ab79b988f9394b428215bb48f3153f168f03345/src/ZipServiceProvider.php#L31
but later, you say, it has to be a string:
https://github.com/zanysoft/laravel-zip/blob/9ab79b988f9394b428215bb48f3153f168f03345/src/Zip.php#L114
https://github.com/zanysoft/laravel-zip/blob/9ab79b988f9394b428215bb48f3153f168f03345/src/Zip.php#L54
so the binding should look something like this:
public function registerCpanelService()
{
$this->app->singleton('zip', function ($app, $parameters) {
return new Zip($parameters[0]);
});
}
because the package has nothing todo with cpanel
but the function is named that way, I guess it´s a simple copy&paste error that happened here 😏
maybe my pull request is okay for you: https://github.com/zanysoft/laravel-zip/pull/43