dataexchangeedu/laravel-data-api-sifuk20

A Laravel wrapper for dataexchangeedu/php-api-sifuk20

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.3.2 2017-08-13 19:11 UTC

This package is not auto-updated.

Last update: 2024-01-20 22:45:15 UTC


README

Laravel 5.3 Source Build Status License

DataExchangeApi provides a simple Laravel wrapper (facade) around the dataexchangeedu/php-data-api-sifuk20 library for use against DataExchange (dataexchange.education).

Quick Installation

  1. Install the package through Composer.

    composer require dataexchangeedu/laravel-data-api-sifuk20
  2. Add the service provider to your project's config/app.php file.

    'providers' => [
        ...
        DataExchange\Laravel\SIFUK20\DataExchangeApiServiceProvider::class,
        ...
    ],
  3. Add the Facade to your project config/app.php file.

    'aliases' => [
        ...
        'DataExchangeApi' => DataExchange\Laravel\SIFUK20\Facades\DataExchangeApi::class,
        ...
    ],
  4. Publish the configuration, models, and migrations into your project.

    php artisan vendor:publish --provider="DataExchange\Laravel\SIFUK20\DataExchangeApiServiceProvider"
  5. Set your connection settings in config\dataexchange-data-api.php.

  6. Start using it!

    <?php
    
    use DataExchangeApi;
    use Exception;
    
    ...
    
    try {
        dd(DataExchangeApi::on('default')->getSchoolInfos());
    } catch (Exception $ex) {
        dd($ex);
    }
    
    ...

    Different ways to call the same thing (assuming ZONEID is in connection school, which is the default connection):

    • DataExchangeApi::getSchoolInfos(); // Implicitly use the default connection
    • DataExchangeApi::on(null)->getSchoolInfos(); // Implicitly use the default connection
    • DataExchangeApi::on('default')->getSchoolInfos(); // Explicitly use the default connection
    • DataExchangeApi::on('school')->getSchoolInfos(); // Explicitly use the school connection
    • DataExchangeApi::getApiInstance()->getSchoolInfos('ZONEID'); // Talk directly using the wrapped API

Debugging

If you need to see a bit more of what the underlying API is doing add the following code to an appropriate place in DataExchange\SIFUK20\ApiClient@callApi. This will enable you to use Fiddler on your host machine and see what the messages look like:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($curl, CURLOPT_PROXY, 'http://10.0.2.2:8888');

Or if it's guzzle based add the following to the send calls:

[
    'proxy' => [
        'http'  => 'http://10.0.2.2:8888',
        'https' => 'https://10.0.2.2:8888',
    ],
    'verify' => false,
]