PHPackages                             scholarslab/bagit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. scholarslab/bagit

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

scholarslab/bagit
=================

0.3.1(6y ago)2712.2k10PHP

Since Jan 8Pushed 6y ago10 watchersCompare

[ Source](https://github.com/scholarslab/BagItPHP)[ Packagist](https://packagist.org/packages/scholarslab/bagit)[ RSS](/packages/scholarslab-bagit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

This repository is no longer maintained.
----------------------------------------

[](#this-repository-is-no-longer-maintained)

We apologize to inform you that this library is no longer maintained. There are some [notes here](./Notes.md) if you wish to continue using this library. Alternatively, there is [BagItTools](https://github.com/whikloj/BagItTools).

---

BagIt PHP
=========

[](#bagit-php)

[![Build Status](https://camo.githubusercontent.com/29706906d9a014cb6a51e3bedf6d980bfac49c4fcc7606cfb1e5a84ec117bae2/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f7363686f6c6172736c61622f42616749745048502e706e673f6272616e63683d646576656c6f70)](http://travis-ci.org/scholarslab/BagItPHP)

This is a PHP implementation of the [BagIt 0.96 specification](https://wiki.ucop.edu/display/Curation/BagIt)

Supported Features:
-------------------

[](#supported-features)

- bag compiling
- manifest and tagmanifest generation
- generation of tag files, bag-info.txt and bagit.txt
- fetching remote files (fetch.txt)
- bag validation

Using Composer
--------------

[](#using-composer)

BagItPHP can be installed using [composer](https://getcomposer.org/) using a package repository. Your `composer.json` will need to look something like this:

```
{
  "require": {
    "scholarslab/bagit": "~0.2"
  }
}
```

Installation
------------

[](#installation)

```
% git clone git://github.com/scholarslab/BagItPHP.git
```

Dependencies
------------

[](#dependencies)

You'll need to have these installed to use this:

- Archive\_Tar ([http://pear.php.net/package/Archive\\\_Tar](http://pear.php.net/package/Archive%5C_Tar))

Example: Creating a bag
-----------------------

[](#example-creating-a-bag)

```
require_once 'lib/bagit.php';

define('BASE_DIR', 'testbag');

// create a new bag at BASE_DIR
$bag = new BagIt(BASE_DIR);

// add a file; these are relative to the data directory
$bag->addFile('../phpunit.xml', 'phpunit.xml');

// update the hashes
$bag->update();

// create a tarball
$bag->package('testbag');

// the bag package will be created at ./testbag.tgz
```

Example: Creating an extended bag, with fetch.txt and bag-info.txt entries
--------------------------------------------------------------------------

[](#example-creating-an-extended-bag-with-fetchtxt-and-bag-infotxt-entries)

```
require_once 'lib/bagit.php';

define('BASE_DIR', 'testbag');

// define some metadata to add to bag-info.txt
$baginfo = array('First-Tag' => 'This is the first tag value',
  'Second-Tag' => 'This is the second tag value'
);

// create a new bag at BASE_DIR
$bag = new BagIt(BASE_DIR, true, true, true, $baginfo);

// add a file; these are relative to the data directory
$bag->addFile('../phpunit.xml', 'phpunit.xml');

// add additional metadata to bag-info.txt
$bag->setBagInfoData('Third-Tag', 'This is the third tag value');

// add some entries to fetch.txt
$bag->fetch->add('http://example.com/bar.htm', 'bar.htm');
$bag->fetch->add('http://example.com/baz.htm', 'baz.htm');

// update the hashes
$bag->update();

// create a tarball
$bag->package('testbag');

// the bag package will be created at ./testbag.tgz
```

Example: Validating an existing bag
-----------------------------------

[](#example-validating-an-existing-bag)

```
require_once 'lib/bagit.php';

// use an existing bag
$bag = new BagIt('test/TestBag.tgz');

// check validity
var_dump((bool)$bag->isValid());
```

Example: Reading a bag
----------------------

[](#example-reading-a-bag)

```
require_once 'lib/bagit.php';

// use an existing bag
$bag = new BagIt('test/TestBag.tgz');

// validate the bag
$bag->validate();

// only execute if a valid bag
if (count($bag->getBagErrors()) == 0) {
  // retrieve remote files
  $bag->fetch->download();

  // copy files
  foreach ($bag->getBagContents() as $filename) {
    copy($filename, 'final/destination/' . basename($filename));
  }
}
```

Feedback
--------

[](#feedback)

We are relying on the [GitHub issues tracker](http://github.com/scholarslab/BagItPHP/issues) linked from the above for feedback. File bugs or other issues [here](http://github.com/scholarslab/BagItPHP/issues).

Tests
-----

[](#tests)

The BagItPHP library includes unit tests to ensure the quality of the software. The easiest way to contribute to the project is to to let us know about andy bugs, and include a test case. Read the build.xml file more more information on running tests, the underlying report types, and packing information.

Note on Patches/Pull Requests
-----------------------------

[](#note-on-patchespull-requests)

- Fork the project
- Make your feature addition/bug fix.
- Add tests for it. This is important so we don't unintentionally break it in a future version
- Commit
- Send us a pull request...bonus points for topic branches.

Kudos
-----

[](#kudos)

Thanks to everyone who's contributed to this:

- [Wayne Graham](https://github.com/waynegraham/)
- [Mark Jordan](https://github.com/mjordan)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~891 days

Total

3

Last Release

2366d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1947622df54ae36e452d376dabdf4bb5fdf9690e18aaef426ce727f19b4b3f49?d=identicon)[scholarslab](/maintainers/scholarslab)

---

Top Contributors

[![whikloj](https://avatars.githubusercontent.com/u/2857697?v=4)](https://github.com/whikloj "whikloj (6 commits)")[![john-devil](https://avatars.githubusercontent.com/u/140092974?v=4)](https://github.com/john-devil "john-devil (2 commits)")[![erochest](https://avatars.githubusercontent.com/u/43783?v=4)](https://github.com/erochest "erochest (1 commits)")[![ubermichael](https://avatars.githubusercontent.com/u/1328893?v=4)](https://github.com/ubermichael "ubermichael (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/scholarslab-bagit/health.svg)

```
[![Health](https://phpackages.com/badges/scholarslab-bagit/health.svg)](https://phpackages.com/packages/scholarslab-bagit)
```

###  Alternatives

[pear/pear

This is the definitive source of PEAR's core files.

1161.7M20](/packages/pear-pear)[browscap/browscap

Browser Capabilities Tools

446115.0k1](/packages/browscap-browscap)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

38244.6k16](/packages/ec-europa-toolkit)[matomo/decompress

12889.5k7](/packages/matomo-decompress)[whikloj/bagittools

A PHP library to manipulate and verify BagIt bags.

1220.5k2](/packages/whikloj-bagittools)[96qbhy/baidu-aip

百度 AI 开放平台 php-sdk

633.9k](/packages/96qbhy-baidu-aip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
