Download the PHP package ludicat/api-gar without Composer

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

GAR API SDK

GAR is a French government SSO mostly used for colleges and high schools. This SDK provide an abstraction layer for PHP integration.

Current GAR version supported : 6.1 - June 2022

Install

Run

composer req ludicat/api-gar

You'll need a PSR-18 http api package, there is an embedded GuzzleAdapter. If you want to create yours, just extends Ludicat\ApiGar\Adapter\AbstractAbonnementWs

composer req php-http/guzzle7-adapter

Quick start

We assume you already applied to the GAR service and for a certified pem key. (remember to provide them with your app "notice")

First, create a client :

$serviceProvider = new \Ludicat\ApiGar\Model\ServiceProvider(
    '123456789', // Your company siret
    \Ludicat\ApiGar\Model\ServiceProvider::ISNI_NONE, // ISNI number or none constant
    'ark:/12345/myRessource' // Your resource ID
);
// Could be another adapter
$adapter = new \Ludicat\ApiGar\Adapter\GuzzleAdapter(
    __DIR__.'/config/cert/app.pem', // Pem key (certified by government)
    __DIR__.'/config/cert/app.key', // Private key
    __DIR__.'/config/cert/harica.crt', // Harica cert
    'Accordeon' // Private key pass,
    Ludicat\ApiGar\Adapter\AbonnementWsInterface::ENDPOINT_DEV // Default one
    // Ludicat\ApiGar\Adapter\AbonnementWsInterface::ENDPOINT_PROD // Once you're ready for production, please use this constant instead.
);
$client = new \Ludicat\ApiGar\Client($adapter, $serviceProvider);

Then you can call for any method :

// Create / retrieve the Abonnement object, you can pass the $serviceProvider for default values preset (recommanded)
$abonnement = new \Ludicat\ApiGar\Model\Abonnement($serviceProvider);
$abonnement
    ->setCommentaireAbonnement('Ceci est un test')
    ->setDebutValidite((new \DateTime())->format('Y-m-d\T00:00:00'))
    ->setAnneeFinValidite(date('Y')  . '-' . (date('Y')+1))
    ->addUaiEtab('0560010G')
    ->setLibelleRessource('Centre de ressources pedagogiques en francais')
    ->setTypeAffectation(\Ludicat\ApiGar\Model\Abonnement::TYPE_INDIV)
    ->setCategorieAffectation(\Ludicat\ApiGar\Model\Abonnement::CATEGORY_TRANSFERABLE)
    ->setNbLicenceGlobale(\Ludicat\ApiGar\Model\Abonnement::UNLIMITED_LICENCE)
    ->setCodeProjetRessource('CODEPRJ001')
;

// Optional, you can validate the object here for easier data control
$validator = new \Ludicat\ApiGar\Validator\AbonnementValidator();
$validatorResponse = $validator->validate($abonnement);
if (!$validatorResponse->isValid()) {
    foreach ($validatorResponse->getViolations() as $violation) {
    printf('%s: %s', $violation->getProperty(), $violation->getMessage());
    echo PHP_EOL;
}

// Send request
$response = $client->create($abonnement);
// $response = $client->update($abonnement);
// $response = $client->delete($abonnement);

// Please note they use 201 (as it should be) for OK create response, not 200
if (201 === $response->getStatusCode()) {
    // Logic
}
// Don't forget to save your idAbonnement somewhere if you used the default generated one

Fetch all Abonnement

// Create client
// Then just call this method 
$result = $client->getAbonnements();

You can filter on specific criteria (as explained in GAR documentation)

$abonnementFilter = new \Ludicat\ApiGar\Model\AbonnementFilter();
$abonnementFilter
    ->setTri(\Ludicat\ApiGar\Model\AbonnementFilter::TRI_DSC) // Default sort column to id abonnement
    ->addFiltre((new \Ludicat\ApiGar\Model\Filtre(
        \Ludicat\ApiGar\Model\Filtre::FILTRE_PUBLIC_CIBLE,
        \Ludicat\ApiGar\Model\Abonnement::PUBLIC_CIBLE_ELEVE
    )))
    ->addFiltre((new \Ludicat\ApiGar\Model\Filtre(
        \Ludicat\ApiGar\Model\Filtre::FILTRE_CATEGORY_AFFECTATION,
        \Ludicat\ApiGar\Model\Abonnement::CATEGORY_TRANSFERABLE
    )))
;

// A list of Abonnement objects
$result = $client->getAbonnements($abonnementFilter);

Fetch all Etablissement

// A list of Etablissement objects
$result = $client->getEtablissements();

Run tests

make tests

All versions of api-gar with dependencies

PHP Build Version
Package Version
Requires ext-simplexml Version *
php Version >=7.3
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 ludicat/api-gar contains the following files

Loading the files please wait ...