Download the PHP package aternos/hangar-api without Composer

On this page you can find all versions of the php package aternos/hangar-api. 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 hangar-api

Aternos/php-hangar-api

An API client for the Hangar API written in PHP.

This client is a combination of code generated by OpenAPI Generator from the Hangar OpenAPI specification and some wrappers around it to improve the usability.

The generated code can be found in src/Api and src/Model. It is recommended to use the wrappers in src/Client instead. The wrappers extend the generated models, so the data returned by the API is available through the getters of the wrapper, e.g. $project->getName(). They also provide methods to fetch related data from the API. These methods start with fetch, e.g. $project->fetchVersions(), and send a request each time they are called. Only fetchProject() of Version and ProjectPage keeps the project once it is known.

Requirements

Installation

Install the package via composer:

Usage

The main entry point for the API is the HangarAPIClient class.

User Agent

It is recommended to set a user agent that identifies your application, ideally including contact information. If you don't set a user agent, the client sends its own user agent including the installed version, e.g. aternos/php-hangar-api/6.0.0. A user agent set with setUserAgent() replaces it.

Authentication

Most endpoints are public. Some endpoints (e.g. the daily stats of projects and versions or editing pages) require an API key, which you can create in your account settings. If an API key is set, it is used for all requests. The client exchanges it for a JWT automatically.

You can check whether the API key has certain permissions, optionally for a specific project:

Error Handling

All methods that send a request throw an Aternos\HangarApi\ApiException if the request fails. The exception code is the HTTP status code of the response. It is also thrown if a required permission is missing, e.g. when requesting daily stats without an API key.

Custom HTTP Client or Configuration

You can pass your own Guzzle client, e.g. to set timeouts or add middlewares, and your own Aternos\HangarApi\Configuration. Each client creates its own configuration if none is passed, so changes to Configuration::getDefaultConfiguration() do not affect the client. A configuration passed to the client is used as is, so set your user agent on it.

Paginated Lists

Most methods return a paginated list (Aternos\HangarApi\Client\List\PaginatedList) which contains the results on the current page and methods to navigate to the next and previous page. The list implements Iterator, ArrayAccess and Countable so you can use it like an array. It also has a getResults() method which returns the underlying array of results.

Projects

Searching for Projects

You can search for a query, apply filters, change the sort order and set the page size. All options are optional and can be combined.

Fetching Projects

Additional Project Data

The Project wrapper provides methods to fetch related data:

The daily stats of a project require an API key of a member of the project:

Compact Projects

Some methods, e.g. the projects a user has starred, return CompactProject objects. They contain less data, but provide the same methods as Project. You can fetch the full project:

Versions

The daily stats of a version require an API key:

Users

Project Pages

Editing pages requires an API key with the edit_page permission for the project:

Development

Updating the Generated Code

Install the OpenAPI Generator and run:


All versions of hangar-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
composer-runtime-api Version ^2.0
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.15.2 || ^8.2
guzzlehttp/psr7 Version ^2.12.3 || ^3.1
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 aternos/hangar-api contains the following files

Loading the files please wait ...