Gogs PHP API Client is a client written in PHP, to easily query a Gogs (Go Git Service) API client.

Joachim M. Giæver 344ce2d69f Added submodule for read me 6 years ago
sami-markdown @ 5ad6e981d2 344ce2d69f Added submodule for read me 6 years ago
src 344ce2d69f Added submodule for read me 6 years ago
.gitignore 216919ecb4 Initial commit 6 years ago
.gitmodules 344ce2d69f Added submodule for read me 6 years ago
LICENSE 216919ecb4 Initial commit 6 years ago
README.md e3669c55d7 Restructure and fix of reserved word 6 years ago
index.php ca9f057629 Refactoring. Classes and spl follows PSR-4 6 years ago
sami.phar c5a5754761 Started readme generation and added missing files 6 years ago

README.md

gogs-php-api-client

A client to query Gogs (https://gogs.io) API from PHP.

Uages:

A guide on how to use will come shortly!

Quick example:

Clone the repo. Set the API_URL and API_TOKEN in the index-file.

$client =  new \Client\GogsAPI(API_URL, API_TOKEN);

$me = $client->user();
$other = $client->user("username");

$repos = $me->get("/repos")->load();

// Loop through every repo
for($repo = $repos->current(); $repo != false; $repo = $repos->next())
    var_dump($repo);

Progress

Users

Search

GET /users/search
$users = $client->users()->search(array("name" => /* username */));

The array-param can be

  • name/q: The username
  • limit: maximum number of results, default: 10

Returns a CollectionResult, e.g

foreach ($users as $user)
    echo $user->ufull_name . "\n";

Get authenticated user

GET /user
$me = $client->user(); // alt: $client->users()->get()

Get a single user

GET /users/:username
$user = $client->user("username"); // alt: $client->users()->get("username")

Create a user

POST /admin/users
$user = $clients->users()->new(
    "new user", "users@email.com"
);

The params should be in the order

  • username (required)
  • email (required)
  • source_id
  • login_name
  • password
  • send_notify

Requires the authenticated user to have admin rights.

Delete a user

DELETE /admin/users/:username
$user->delete();

Requires the authenticated user to have admin rights.

Get a user's repos

GET /user/repos

or

GET /users/:username/repos
$repos = $user->repos()->load();

Get specific user's repo

GET /repos/:owner/:repo
$repo = $user->repo( /* repo */ );

Create a user's repo

POST /user/repos

or

POST /admin/users/:username/repos
$user->repos()->new(
    "name"
);

The params should be in the order

  • name
  • description
  • private
  • bool
  • auto_init
  • gitignores
  • license
  • readme

Requires the authenticated user to have admin rights to be able to create repos for other users than itself.

Delete a user's repo

DELETE /repos/:owner/:repo
$repo->delete();

Requires the authenticated user to have admin rights to be able to delete repos for other users than itself.

Get a user's organizations

GET /user/orgs

or

GET /users/:username/orgs
$orgs = $user->organizations();

Organizations

Get an organizations repositories

GET /orgs/:orgname/repos
$org = $user->organizations()->load()->current();

$repos = $org->repos();