2017 © Pedro Peláez
 

library xml-authoring-library

Holding code that is reused by more than one component of the xmlsquad xml authoring suite of projects.

image

xmlsquad/xml-authoring-library

Holding code that is reused by more than one component of the xmlsquad xml authoring suite of projects.

  • Monday, July 2, 2018
  • by forikal-uk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

xml-authoring-library

This is a place to put code that is reused by many commands which are part of the xml-authoring-tools suite., (*1)

Created as a place to put code which is re-used by two or more projects in the xmlsquad xml-authoring suite., (*2)

See the related Issue that triggered the creation of this project., (*3)

Common Documentation

A library of help pages. I.e Information that is relevant to more than one project in this suite of projects., (*4)

This project can be added to your project via composer

$ composer require xmlsquad/xml-authoring-library --prefer-source

If you would like to develop both the library and, say a command that uses it in tandem. I beleive that composer allows you to grab the library as source, (*5)

See : composer require, (*6)

Quote:, (*7)

The option: --prefer-source: Install packages from source when available., (*8)

and see Composer Repositories > Packages, (*9)

Quote:, (*10)

Source: The source is used for development. This will usually originate from a source code repository, such as git. You can fetch this when you want to modify the downloaded package., (*11)

Code Reference

Google API helper

An abstraction over Google API SDK. It helps to mock Google API in tests and authenticate users in console commands., (*12)

You need to install Google SDK to your project to use this helper:, (*13)

composer require google/apiclient:^2.0

Usage example:, (*14)

use XmlSquad\Library\GoogleAPI\GoogleAPIClient;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class MyCommand extends Command
{
    execute(InputInterface $input, OutputInterface $output)
    {
        $googleClient = new GoogleAPIClient(); // You can pass a \Google_Client mock to the constructor. It will be used in the Google services.

        if (!$googleClient->authenticateFromCommand(
            $input,
            $output
            'google-client-secret.json', // A path to a Google API client secret file
            'google-access-token.json', // A path to a file where to store a Google API access token so the helper won't prompt to authenticate next time
            [\Google_Service_Drive::DRIVE_READONLY, \Google_Service_Sheets::SPREADSHEETS_READONLY] // A list of required permissions
        )) {
            return 1;
        }

        // $googleAPIClient->driveService is a \Google_Service_Drive instance. All the other services are available.
        $file = $googleAPIClient->driveService->files->get('87ad6fg90gr0m91c84');

        return 0;
    }
}

You can learn how to get the Google API client secret file from this instruction. If you need to customize the console messages and behaviour, use the authenticate method. You can find more information in the source code., (*15)

Console logger

A PSR-3 compatible logger which writes messages to a Symfony console output. In contrast to the built-in Synfony Console logger, this doesn't print log level labels and is customizable (we can edit the source code)., (*16)

Usage example:, (*17)

use XmlSquad\Library\Console\ConsoleLogger;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Psr\Log\LogLevel;

// ...

protected function execute(InputInterface $input, OutputInterface $output)
{
    $consoleLogger = new ConsoleLogger($output, [
        LogLevel::DEBUG  => OutputInterface::VERBOSITY_VERY_VERBOSE,
        LogLevel::INFO   => OutputInterface::VERBOSITY_VERBOSE,
        LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL
    ], [
        LogLevel::DEBUG  => '',
        LogLevel::INFO   => '',
        LogLevel::NOTICE => 'info'
    ]);

    $service = new MyService($consoleLogger);
}

The constructor arguments are the same as in the Synfony Console logger., (*18)

Contribution

  1. Clone the repository.
  2. Install the dependencies by running composer install in a console.
  3. Make a change. Make sure the code follows the PSR-2 standard.
  4. Test the code by running composer test. If the test fails, fix the code.
  5. Commit and push the changes.

The Versions

02/07 2018

dev-master

9999999-dev

Holding code that is reused by more than one component of the xmlsquad xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

25/06 2018

v0.2.7

0.2.7.0

Holding code that is reused by more than one component of the xmlsquad xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

24/06 2018

v0.2.6

0.2.6.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

24/06 2018

v0.2.5

0.2.5.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

24/06 2018

v0.2.4

0.2.4.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

03/06 2018

v0.2.3

0.2.3.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

03/06 2018

v0.2.2

0.2.2.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

02/06 2018

v0.2.1

0.2.1.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

01/06 2018

v0.2.0

0.2.0.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

01/06 2018

v0.0.5

0.0.5.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

31/05 2018

v0.0.4

0.0.4.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

31/05 2018

v0.0.3

0.0.3.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

30/05 2018

v0.0.2

0.0.2.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0

30/05 2018

v0.0.1

0.0.1.0

Holding code that is reused by more than one component of the forikal xml authoring suite of projects.

  Sources   Download

Apache-2.0