dev-master
9999999-dev https://github.com/netvlies/NetvliesBasecampBundleBundle around the Basecamp API client
MIT
The Requires
- php >=5.3.0
- netvlies/basecamp-php >=1.0
by Richard van den Brand
api basecamp 37signals
Bundle around the Basecamp API client
Symfony2 bundle around the basecamp-php client. It provides an easy way to integrate the new Basecamp API in your project., (*2)
Use Composer to install the bundle:, (*3)
$ composer.phar require netvlies/basecamp-bundle
Enable the bunble in your kernel:, (*4)
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Netvlies\Bundle\BasecampBundle\NetvliesBasecampBundle(), ); }
This bundle supports authentication via HTTP authentication (easy and quick) or OAuth (a little bit more difficult)., (*5)
Below is an example of the minimal configuration using HTTP authentication. Only thing you need to do is supply your own credentials., (*6)
# app/config/config.yml netvlies_basecamp: authentication: http app_name: My Funky Application app_contact: http://www.myfunkyapplication.com identification: user_id: 1234 username: your@username.com password: secret
If you have a more advanced use case you probably want to use OAuth. To implement OAuth in your Symfony2 project we recommend the HWIOAuthBundle., (*7)
First start by implementing the Netvlies\Bundle\BasecampBundle\OAuth\CredentialsProviderInterface
. Below is an simple example assuming you store the OAuth data in your User
entity:, (*8)
namespace Acme\Bundle\MainBundle\OAuth; use Netvlies\Bundle\BasecampBundle\OAuth\CredentialsProviderInterface; use Symfony\Component\Security\Core\SecurityContext; class BasecampCredentialsProvider implements CredentialsProviderInterface { protected $context; public function __construct(SecurityContext $context) { $this->context = $context; } public function getBasecampId() { if (! $this->context->isGranted('IS_AUTHENTICATED_FULLY')) { throw new \RuntimeException('Please login before using Basecamp'); } return $this->context->getToken()->getUser()->getBasecampId(); } public function getToken() { if (! $this->context->isGranted('IS_AUTHENTICATED_FULLY')) { throw new \RuntimeException('Please login before using Basecamp'); } return $this->context->getToken()->getUser()->getToken(); } }
Now register this as a service:, (*9)
services: acme.basecamp.oauth_credentials_provider: class: Acme\Bundle\MainBundle\OAuth\BasecampCredentialsProvider arguments: ["@security.context"]
Finally supply the service id into the bundle configuration like this:, (*10)
netvlies_basecamp: authentication: oauth app_name: My Funky Application app_contact: http://www.myfunkyapplication.com oauth: credentials_provider: acme.basecamp.oauth_credentials_provider
You can now get the client from the container and use it:, (*11)
$client = $this->get('basecamp'); $project = $client->getProject(array( 'projectId' => 1 ));
Bundle around the Basecamp API client
MIT
api basecamp 37signals