Download the PHP package dagstuhl/swh-archive-client without Composer

On this page you can find all versions of the php package dagstuhl/swh-archive-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swh-archive-client

SWH

dagstuhl/swh-archive-client

A SoftwareHeritage web API client in php

This project provides a php wrapper around the SoftwareHeritage web API. It is used by Dagstuhl Publishing to integrate automatic archiving of software projects by authors into its publication workflow.

At https://github.com/dagstuhl-publishing/swh-deposit-client, we also provide a php client for the SoftwareHeritage Deposit API.

Installation

The client is designed to work smoothly with the config mechanism of laravel. When used inside a laravel project, you can configure it by creating a file swh.php inside the config folder with the following contents:

Based on that configuration, a default client is implicitly initialized and used whenever you request a SwhObject. In a non-laravel environment just implement a global config function config in such a way that config('swh.web-api.token') is your token, config('swh.web-api.url') is the api url, and so on.

Code Examples

1) Browsing the archive

Searching through the archive is quite intuitive, as you don't realise that you are dealing with an API. You simply request the relevant objects, like this:

Further supported objects are Revision, Release, Directory, Content. To fetch an object by its id, just call the byId method:

To identify a directory/file inside a snapshot, use the Context class. Continuing the example from above, we can do the following:

2) Archiving a repository

3) Error Handling

If null is returned instead of an object of the requested type, that indicates that an error has occurred. More information about the error can be obtained from the current SwhWebApiClient instance like so:

4) Caching and rate limit

To reduce the number of requests, all requests except for the /origin/ and the /stat/counters/ endpoint are cached. The cache folder has to specified as absolute path in config('swh.web-api.cache-folder'). To clear the cache, you can use the clearCache command:

To obtain information about your rate-limiting, call $swhClient->getRateLimits();. This will return an array of the following type:


All versions of swh-archive-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.9
nesbot/carbon Version ^2||^3
kevinrob/guzzle-cache-middleware Version ^5.1
league/flysystem Version ^3.28
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dagstuhl/swh-archive-client contains the following files

Loading the files please wait ....