ochi51 / cybozu-http-bundle
Symfony2 HTTP client bundle for cybozu.com API (kintone API and User API)
Installs: 16 796
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.0
- ochi51/cybozu-http: ^1.0
- symfony/framework-bundle: ~3.1
Requires (Dev)
README
Symfony bundle that integrates the Cybozu HTTP by providing easy-to-use services and configuration.
cybozu.com API Documentation
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.
- 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.