lsolesen/edbbrugs-php-sdk

PHP-SDK for integrating with EDB-BRUGS which is a platform used by the free schools in Denmark for managing students.

0.5.3 2021-10-08 10:27 UTC

This package is auto-updated.

Last update: 2024-11-08 17:29:09 UTC


README

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License

PHP 7 SDK to communicate with De frie skolers EDB-BRUGS.

Requirements

  • Access to the programs from EDB-BRUGS.
  • License for "Webtilmeldinger" (contact EDB-BRUGS support)
  • EDB-BRUGS uses the new "stamdata" system

Getting started

The service communicates via SOAP to EDB-BRUGS. You are only able to create new registrations which has to manually manipulated and put into the correct courses using the EDB-BRUGS Windows program.

To get access to the service, you need to contact the support at EDB-BRUGS. You need following information:

  • WSDL for the SOAP-service (append ?wsdl to the WSDL-endpoint you recieve from EDB-BRUGS)
  • Username
  • Password
  • School Code

Installation

Composer

Simply add a dependency on lsolesen/edbbrugs-php-sdk to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a dependency on EDBBrugs-PHP-SDK:

{
    "require": {
        "lsolesen/edbbrugs-php-sdk": "0.2.*"
    }
}

After running composer install, you can take advantage of Composer's autoloader in vendor/autoload.php.

Usage

<?php
use EDBBrugs\Client;
use EDBBrugs\Credentials;
use EDBBrugs\RegistrationRepository;

$soap = new \SoapClient('https://www.webtilmeldinger.dk/TilmeldingsFormularV2Ws/Service.asmx?wsdl', array('trace' => 1));
$credentials = new Credentials($username, $password, $school_code);
$client = new Client($credentials, $soap);
$registration_repository = new RegistrationRepository($client);

// Add registrations.
$registrations = array(
    array(
        'Kartotek' => 'XX', // required - provided by the user of EDB-Brugs
        'Kursus' => 'Vinterkursus 18/19', // required - name of the course
        // The following is available for Elev, Mor, Far, Voksen
        'Elev.Fornavn' => 'Svend Aage',
        'Elev.Efternavn' => 'Thomsen',
        'Elev.Adresse' => 'Ørnebjergvej 28',
        'Elev.Lokalby' => 'Grejs',
        'Elev.Postnr' => '7100',
        'Elev.Bynavn' => 'Vejle',
        'Elev.CprNr' => '010119421942',
        'Elev.Fastnet' => '75820811',
        'Elev.FastnetBeskyttet' => 0, // 0 = No, 1 = Yes
        'Elev.Mobil' => '75820811',
        'Elev.MobilBeskyttet' => 0, // 0 = No, 1 = Yes
        'Elev.Email' => 'kontor@vih.dk',
        'Elev.Land' => 'Danmark',
        'Elev.Notat' => 'Svend Aage Thomsen er skolens grundlægger',
        'Elev.Linje' => 'Fodbold', // optional and specific for a student
        // You can add Far, Mor, Voksen - but only one of each
        'Voksen.Fornavn' => 'Svend Aage',
        'Voksen.Efternavn' => 'Thomsen',
        'Voksen.Adresse' => 'Ørnebjergvej 28',
        'Voksen.Lokalby' => 'Grejs',
        'Voksen.Postnr' => '7100',
        'Voksen.Bynavn' => 'Vejle',
        'Voksen.Fastnet' => '75820811',
        'Voksen.FastnetBeskyttet' => 0, // 0 = No, 1 = Yes
        'Voksen.Mobil' => '75820811',
        'Voksen.MobilBeskyttet' => 0, // 0 = No, 1 = Yes
        'Voksen.Email' => 'kontor@vih.dk',
        'Voksen.Land' => 'Danmark',
    )
);

$registration_repository->addRegistrations($registrations);

// Get new registrations.
$registration_repository->getNewRegistrations();

// Get handled registrations.
$registration_repository->getHandledRegistrations();
?>

If you need to put something into custom fields, you will have to do like this:

// Add registrations.
$registrations = array(
    array(
        'Kartotek' => 'XX', // required - provided by the user of EDB-Brugs
        'EgneFelter.EgetFelt30' => '[Forening450l]12.12.2018 Web Ja'
    )
);

Testing

You can test the methods on the commandline, by running:

php vendor/bin/phpunit --exclude-group=IntegrationTest tests

If you want to test the integration, please create a ´phpunit.xml´ based on ´phpunit.dist.xml´ with the correct information for accesssing the service.

php vendor/bin/phpunit tests

During testing you need to manually delete the web registrations using the Windows EDB-BRUGS program. There is no way to delete using the SOAP webservice.