Crea un archivo en un archivo zip usando un contenedor de flujo

Quiero usar un contenedor de flujo zip en PHP para crear un archivo zip o agregar archivos en un archivo zip. Aquí está mi ejemplo:

<?php
echo file_get_contents('zip://file.zip#existing_file.txt');
file_put_contents('zip://file.zip#new_file.txt', 'Trying to put some stuff here...');
echo file_get_contents('zip://file.zip#new_file.txt');

Este código me da esta salida:

$ php test.php 
Hey, I'm an existing text in a file in a zip archive !

Warning: file_put_contents(zip://file.zip#new_file.txt): failed to open stream: operation failed in /home/sylvain/test.php on line 7

Warning: file_get_contents(zip://file.zip#new_file.txt): failed to open stream: operation failed in /home/sylvain/test.php on line 9

Recibo el mismo error cuando el archivo zip simplemente no existe.

Aquí están los permisos de archivo:

$ ls -la
total 24
drwxrwxrwx   2 sylvain sylvain  4096 2009-11-13 14:44 .
drwxr-xr-x 134 sylvain sylvain 12288 2009-11-13 14:44 ..
-rwxrwxrwx   1 sylvain sylvain   236 2009-11-13 14:44 file.zip
-rwxrwxrwx   1 sylvain sylvain   268 2009-11-13 14:44 test.php

¿Es posible hacer lo que estoy tratando de hacer sin crear un nuevo contenedor de flujo?

Respuestas a la pregunta(2)

Su respuesta a la pregunta