ochi51/cybozu-http-bundle

There is no license information available for the latest version (1.0.0) of this package.

Symfony2 HTTP client bundle for cybozu.com API (kintone API and User API)

1.0.0 2016-10-28 01:49 UTC

This package is auto-updated.

Last update: 2024-10-17 22:18:20 UTC


README

Circle CI Scrutinizer Code Quality Code Coverage Build Status

Symfony bundle that integrates the Cybozu HTTP by providing easy-to-use services and configuration.

cybozu.com API Documentation

Japanese English

Requirements

  • PHP >=5.5
  • Composer
  • Symfony >=3.1

Installation

The recommended way to install Cybozu HTTP is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

    $ curl -sS https://getcomposer.org/installer | php
    $ mv composer.phar /usr/local/bin/composer

You can add Cybozu HTTP as a dependency using the composer

    $ composer require ochi51/cybozu-http-bundle

Alternatively, you can specify Cybozu HTTP as a dependency in your project's existing composer.json file:

    {
       "require": {
          "ochi51/cybozu-http-bundle": "^1.0"
       }
    }

After installing, you need to register the bundle in your application.

    // app/AppKernel.php
    class AppKernel extends Kernel
    {
        // ...
        public function registerBundles()
        {
            $bundles = array(
                // ...
                new CybozuHttpBundle\CybozuHttpBundle()
            );
        }
    }

Configuration

There are two ways that configure cybozu.com account information.

  1. User entity has it.
    # app/config.yml
    cybozu_http:
        cert_dir:       /path/to/cert_dir
        logfile:        /path/to/logfile.log
    use CybozuHttpBundle\Entity\UserInterface;
    
    class User implements UserInterface
    {
        public function getCybozuHttpConfig()
        {
            return [
                "domain" =>         "cybozu.com",
                "subdomain" =>      "changeMe",
                "use_api_token" =>    false,
                "login" =>          "changeMe",
                "password" =>       "changeMe",
                "token" =>          null,
                "use_basic" =>       false,
                "basic_login" =>     null,
                "basic_password" =>  null,
                "use_client_cert" =>  false,
                "cert_file" =>       "cert.pem",
                "cert_password" =>   null
            ];
        }
        
        public function getDebugMode()
        {
            return true;
        }
    }

Quick example

    <?php
    // AppBundle\Controller\MyCybozuHttpController
    
    public function getRecordAction($appId, $recordId)
    {
        $api = $this->get('cybozu_http.kintone_api_client');
        $record = $api->record()->get($appId, $recordId);
        // do something
    }

Testing

To run the tests, Run the following command from the project folder.

    $ php ./bin/phpunit

TODO

  • Japanese documentation.

License

The MIT License (MIT). Please see LICENSE for more information.