PHPackages                             ciricihq/api-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ciricihq/api-bundle

ActiveSymfony-bundle[API Development](/categories/api)

ciricihq/api-bundle
===================

Symfony API to manage Push Notifications

0558PHP

Since Oct 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ciricihq/ApiBundle)[ Packagist](https://packagist.org/packages/ciricihq/api-bundle)[ RSS](/packages/ciricihq-api-bundle/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Cirici API Bundle
=================

[](#cirici-api-bundle)

User access API to allow users to login against.

The authentication is made with [oauth2 specification](http://tools.ietf.org/html/rfc6749)The bundle used to handle oauth2 authentication is [FOSOAuthServerBundle](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle)

A good starting point to understand the authentication proces is to check this tutorial: [OAuth2 explained](http://blog.tankist.de/blog/2013/07/16/oauth2-explained-part-1-principles-and-terminology/)

Installation
------------

[](#installation)

In order to use this bundle you have to add the next lines to config.yml

```
# FOSUser configs
fos_user:
    db_driver: orm
    firewall_name: api
    user_class: Cirici\ApiBundle\Entity\User
    from_email:
        address:              webmaster@api.cirici.com
        sender_name:          webmaster
    resetting:
        token_ttl:            21600 # 6 hours i guess
        email:
            template:             'FOSUserBundle:Resetting:email.txt.twig'
            from_email:
                address:              webmaster@api.cirici.com
                sender_name:          webmaster

# FOSRest configs
fos_rest:
    param_fetcher_listener: true
    view:
        view_response_listener: force
    routing_loader:
        default_format: json
    serializer:
        serialize_null: true

# FOSOAuth configs
fos_oauth_server:
    db_driver: orm
    client_class: Cirici\ApiBundle\Entity\Client
    access_token_class: Cirici\ApiBundle\Entity\AccessToken
    refresh_token_class: Cirici\ApiBundle\Entity\RefreshToken
    auth_code_class: Cirici\ApiBundle\Entity\AuthCode
    service:
        user_provider: fos_user.user_manager
        options:
            supported_scopes: user

# In order to override the User entity you have to add the next lines
# this changes the pointer of all the relationships to user bundle
doctrine:
    orm:
        resolve_target_entities:
            Cirici\ApiBundle\Model\UserInterface: Cirici\YourBrandNewBundle\Entity\SomeUserEntity
```

You should add the next lines to `routing.yml` as well:

```
cirici_api:
    resource: "@CiriciApiBundle/Resources/config/routing.yml"
    prefix:   /

fos_oauth_server_token:
    resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml"

fos_oauth_server_authorize:
    resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml"

cirici_oauth_server_auth_login:
    pattern: /oauth/v2/auth_login
    defaults: { _controller: CiriciApiBundle:Security:login }

cirici_oauth_server_auth_login_check:
    pattern: /oauth/v2/auth_login_check
    defaults: { _controller: FOSUserBundle:Security:check }
```

Enabling user call in routing.yml:

```
cirici_oauth_server_user:
    pattern: /api/user
    defaults: { _controller: CiriciApiBundle:ApiUser:user }
```

Create oauth2 clients
---------------------

[](#create-oauth2-clients)

The first thing you should create to allow users login to the API is create the Clients, the client is the types of entities will able to authenticate against our oauth server. A client could be one for the mobile apps using the API, other for allowing access to other APIs to our API, other for web users, and so on.

```
php app/console cirici:oauth-server:client:create --redirect-uri="CLIENT_HOST" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials"

```

You can define wich grant types will accept this Client, in the example we enable all of them. But the Password Grant type is what is planned to use with this project.

When you create a client you will get the next important information (You can check it in its database table):

- public\_id: The Client ID
- secret: The secret generated needed to use this Client

Getting AccessToken a.k.a login
-------------------------------

[](#getting-accesstoken-aka-login)

To perform the login with a web form you can check the next url:

/oauth/v2/auth\_login

Or you can send those parameters:

- client\_id
- client\_secret
- grant\_type = 'password'
- username
- password

throught POST (Or maybe headers) to the next url:

/oauth/v2/token

As a result you will get the next info:

- access\_token: The info you asked for
- expires\_in: The lifetime it has
- token\_type: The type of the token
- scope: The scope applied to the token
- refresh\_token: The RefreshToken value used to renew the AccessToken

Using RefreshToken
------------------

[](#using-refreshtoken)

AccessToken has a lifetime of one hour (3600s), so each time is outdated we should ask for a new AccessToken using the RefreshToken.

To refresh the AccessToken when it expires whe should do the next:

Send those parameters:

- client\_id
- client\_secret
- grant\_type = 'refresh\_token'
- refresh\_token

to:

/oauth/v2/token

As a result yo'll get the same as the AccessToken call with a new AccessToken

You can check the Tests on the project to see how are the flows.

User entity
-----------

[](#user-entity)

[User inheritance](http://stackoverflow.com/questions/9801173/creating-portable-bundles-with-extendable-entities-in-symfony2)

Resetting Password
------------------

[](#resetting-password)

To request a reset password you should send by POST the next parameters:

- username (should be the user email or the username, in our case we will use the email address)

to:

/api/resetting/send-email

This call will send an email to specified user with the url to reset his password. This call will be a web form fit reset password form.

Problems
--------

[](#problems)

If you have problems with Doctrine proxy classes generation you should run:

```
app/console cache:warmup --env=prod --no-debug

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cbcbe685af90849bdd806d22ba8c315093bdeb6b2c46c874108b69f81c23038?d=identicon)[gtrias](/maintainers/gtrias)

![](https://www.gravatar.com/avatar/d8f46469b5c3f5f745308d4edb9c55afbd160e0193da99e903365ea82b749cee?d=identicon)[elboletaire](/maintainers/elboletaire)

### Embed Badge

![Health badge](/badges/ciricihq-api-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ciricihq-api-bundle/health.svg)](https://phpackages.com/packages/ciricihq-api-bundle)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
