Giter Club home page Giter Club logo

Comments (2)

wapmorgan avatar wapmorgan commented on August 26, 2024

You should point directories which should be archived. There is no way to exclude subfolders.

I propose this way

$folders = glob(__DIR__.'/*');
$ignored_files = ['tests', 'logs'];
$folders = array_filter($folders, function ($dir) use ($ignored_files) {return !in_array(basename($dir), $ignored_files, true);});
// uncomment if need to save folders with relative path (without full path)
// $folders = array_combine(array_map('basename', $folders), $folders);
\wapmorgan\UnifiedArchive\UnifiedArchive::archiveFiles($folders, '/tmp/test.zip');

If need to exclude files&folders by basename in all tree, this needs more complicated work:

$folders = glob(__DIR__.'/*');

// exclude top-level folders from archiving list
$ignored_files = ['tests', 'logs'];
$folders = array_filter($folders, function ($dir) use ($ignored_files) {return !in_array(basename($dir), $ignored_files, true);});

$info = \wapmorgan\UnifiedArchive\UnifiedArchive::prepareForArchiving($folders, '/tmp/test.zip');
$files = array_filter($info['files']); // delete empty entries - from folders
$ignored_subfolders = ['src', 'composer', 'nikic'];
$filtered_files = array_filter($files, function ($file) use ($ignored_subfolders) {return !preg_match('~/(' . implode('|', $ignored_subfolders) . ')/~', $file); }); // ignore by /folder/ pattern
\wapmorgan\UnifiedArchive\UnifiedArchive::archiveFiles($filtered_files, '/tmp/test2.zip');

from unifiedarchive.

patriceckhart avatar patriceckhart commented on August 26, 2024

I didn't think of that, but it's a good idea to read the directory first and if necessary, unsetter the folders you don't want. Thank you @wapmorgan

from unifiedarchive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.