Zippy
Zippy copied to clipboard
0.4.9 fatal error 'ProcessBuilder not found'
v0.4.8
still works fine, but upgrading to 0.4.9
and then running this exact code gives me a fatal error.
Here's how I'm using Zippy:
use Alchemy\Zippy\Zippy;
use function Zeek\PHP_Util\rrmdir;
/**
* Load all the composer packages
*/
require_once __DIR__ . '/vendor/autoload.php';
function generate_zip_file() {
$toolkit_filename = 'toolkit.zip';
$vendor_dir = __DIR__ . '/vendor';
// Creates an archive.zip that contains a directory "folder" that contains
// files contained in "/path/to/directory" recursively
$zippy = Zippy::load();
// Make our tmp directory
if ( ! file_exists( __DIR__ . '/tmp' ) ) {
mkdir( __DIR__ . '/tmp' );
}
$paths = [
'index',
'buttons',
'breadcrumbs',
];
foreach ( $paths as $path ) {
generate_path_html( $path );
}
$archive = $zippy->create( $toolkit_filename, [
'vendor' => $vendor_dir,
'index.html' => __DIR__ . '/tmp/index.html',
'buttons.html' => __DIR__ . '/tmp/buttons.html',
], true );
// Remove the tmp directory
rrmdir( __DIR__ . '/tmp' );
}
function generate_path_html( $path = 'index' ) {
ob_start();
echo shell_exec( 'php index.php ' . $path );
$path_html = ob_get_clean();
file_put_contents( "tmp/{$path}.html", $path_html );
}
generate_zip_file();
die;
And here's the error:
PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Process\ProcessBuilder' not found in /dev/sites/example/htdocs/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php:69
Stack trace:
#0 /dev/sites/example/htdocs/vendor/alchemy/zippy/src/Adapter/VersionProbe/ZipVersionProbe.php(70): Alchemy\Zippy\ProcessBuilder\ProcessBuilderFactory->create()
#1 /dev/sites/example/htdocs/vendor/alchemy/zippy/src/Adapter/AbstractAdapter.php(146): Alchemy\Zippy\Adapter\VersionProbe\ZipVersionProbe->getStatus()
#2 /dev/sites/example/htdocs/vendor/alchemy/zippy/src/Zippy.php(156): Alchemy\Zippy\Adapter\AbstractAdapter->isSupported()
#3 /dev/sites/example/htdocs/vendor/alchemy/zippy/src/Zippy.php(67): Alchemy\Zippy\Zippy->getAdapterFor('zip')
#4 /dev/sites/example/htdocs/script.php(42): Alchemy\Zippy\Zippy->create('toolkit.zip', Array, true)
#5 /dev/sites/example/htdocs/script.php(58): ETT\g in /dev/sites/example/htdocs/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php on line 69
I'm getting this error too, have tried running composer dump-autoload
but hasn't helped. Had a look through the code and couldn't see the issue. Also using version 0.4.9
.
Seems the pr #140 actually broke this package completely. The complete symfony/process signature changed. There won't be an easy way to cover Symfony 4 without breaking backward compatibility.
PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Process\ProcessBuilder' not found in /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php:69
Stack trace:
#0 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Adapter/VersionProbe/ZipVersionProbe.php(70): Alchemy\Zippy\ProcessBuilder\ProcessBuilderFactory->create()
#1 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Adapter/AbstractAdapter.php(146): Alchemy\Zippy\Adapter\VersionProbe\ZipVersionProbe->getStatus()
#2 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Zippy.php(156): Alchemy\Zippy\Adapter\AbstractAdapter->isSupported()
#3 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Zippy.php(67): Alchemy\Zippy\Zippy->getAdapterFor('zip')
#4 /Users/luceos/Sites/flarum/workbench/backup/src/Console/BackupCommand.php(69): Alchemy\Zippy\Zippy->create('/Users/luceos/S...', Array)
#5 /Users/luceos/Sites/flarum/workbench/backup/src/Console/BackupCommand.php(32): Flagrow\Backup\Console\BackupCommand->prepareArchive()
#6 [intern in /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php on line 69
Fixing that, causes:
PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Process\Process::add() in /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Adapter/VersionProbe/ZipVersionProbe.php:71
Stack trace:
#0 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Adapter/AbstractAdapter.php(146): Alchemy\Zippy\Adapter\VersionProbe\ZipVersionProbe->getStatus()
#1 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Zippy.php(156): Alchemy\Zippy\Adapter\AbstractAdapter->isSupported()
#2 /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Zippy.php(67): Alchemy\Zippy\Zippy->getAdapterFor('zip')
#3 /Users/luceos/Sites/flarum/workbench/backup/src/Console/BackupCommand.php(69): Alchemy\Zippy\Zippy->create('/Users/luceos/S...', Array)
#4 /Users/luceos/Sites/flarum/workbench/backup/src/Console/BackupCommand.php(32): Flagrow\Backup\Console\BackupCommand->prepareArchive()
#5 [internal function]: Flagrow\Backup\Console\BackupCommand->handle(Object(Flagrow\Backup\Registry))
#6 /Users/luceos/Sites/flarum/vendor/illuminate/container/Bound in /Users/luceos/Sites/flarum/vendor/alchemy/zippy/src/Adapter/VersionProbe/ZipVersionProbe.php on line 71
Having the same issue and error here Uncaught Error: Class 'Symfony\Component\Process\ProcessBuilder' not found
Updating broke all of my zippy code...
ProcessBuilder was deprecated in symfony/component 3.4.0 and removed in symfony/component 4.0 see https://github.com/symfony/process/blob/master/CHANGELOG.md
Someone has information about the progress of this issue, I still have the problem but I saw that a PR was open to solve this problem, will it soon be merge?
Is this library just broken and dead?
ProcessBuilder is not available in symfony/process 4. Need to upgrade zippy to cover this case.
Example of fixing this case in another project - https://github.com/pact-foundation/pact-php/pull/61/files
@luceos Are you a maintainer of this package?
Right now the only way to fix is to require symfony/process with version symfony/process": "^2.1 || ^3.0"
As I had to upgrade Symfony and the maintainers of the project stopped to "maintain", I had no choice other than creating a nasty patch, that allows to use the zipper by ignoring the "ZipVersionProbe" functionality. I don´t know what the ZipVersionProbe class it is meant to do as I can't afford to spend more time with researching.
With me it works. Even with larger files 200mb+
Maybe this is a small help to somebody who runs into the same issue.
@luceos Are you a maintainer of this package? Right now the only way to fix is to require symfony/process with version
symfony/process": "^2.1 || ^3.0"
I'm not. And I don't remember using this in my apps anymore.
If you need this, I highly suggest forking and adding a link to the fork here.