PHP code example of plugin / openpub-internal-data

1. Go to this page and download the library: Download plugin/openpub-internal-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

plugin / openpub-internal-data example snippets


// OpenPubServiceProvider.php

$this->app->singleton('openpub.items.internal', function ($app) {
    $config = [
        'base_uri' => env('OPENPUB_ENDPOINT'),
    ];

    if (env('OPENPUB_APPLICATION_USERNAME') && env('OPENPUB_APPLICATION_PASSWORD')) {
        $config['auth'] = [
            env('OPENPUB_APPLICATION_USERNAME'),
            env('OPENPUB_APPLICATION_PASSWORD'),
        ];
    }

    return new Repository(new Client($config));
});

// OpenPubController.php

public function show(Request $request, $title)
    {
        if (\is_user_logged_in()) {
            $repository = app()->make('openpub.items.internal');
        } else {
            $repository = app()->make('openpub.items');
        }

        // etc