PHPackages                             trialog/p4s-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. trialog/p4s-api-bundle

ActiveLibrary[API Development](/categories/api)

trialog/p4s-api-bundle
======================

Un bundle PHP / Symfony2 permettant une intégration facile de l'API du P4S - Projet AMISURE

v0.9(12y ago)118LGPL-3PHPPHP &gt;=5.3.3

Since Jan 6Pushed 11y ago2 watchersCompare

[ Source](https://github.com/trialog/p4s-api-bundle)[ Packagist](https://packagist.org/packages/trialog/p4s-api-bundle)[ RSS](/packages/trialog-p4s-api-bundle/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (15)Versions (3)Used By (0)

AMISURE - P4S API
=================

[](#amisure---p4s-api)

[![Latest Stable Version](https://camo.githubusercontent.com/0d73221cd043eb3a074bccceeeda79f1198ca7d09d48eccebeea9591768665fd/68747470733a2f2f706f7365722e707567782e6f72672f747269616c6f672f7034732d6170692d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/trialog/p4s-api-bundle)

La plateforme P4S du projet de recherche français AMISURE () offre une API REST. Cette bibliothèque fournit un bundle Symfony2 permettant une intégration facilitée avec cette API. Plus besoin de se soucier de l'API REST bas niveau, il est possible de manipuler directement des objets PHP.

Features
--------

[](#features)

- Authenticate to the P4S - OAuth 2.0, using the classical Symfony2 login workflow
- Access to the P4S API using PHP methods and objects
    - Retrieve beneficiary information
    - List organisations and their users
    - Create and list events of the beneficiary agenda
    - Create link between the beneficiary and organisations or organisation users
    - Create and list the evaluations of the beneficiary

Installation &amp; Usage
------------------------

[](#installation--usage)

Add this library to your Symfony2 project using your Composer file. You need to add the following dependencies:

```
"require" : {
	"php" : ">=5.3.3",
	"hwi/oauth-bundle" : "dev-master",
	"trialog/p4s-api-bundle" : "dev-master",
	"zumba/json-serializer" : "dev-master"
}

```

Normally, only "trialog/p4s-api-bundle" should be required, but a known bug prevents us to use this alone.

Then, you need to add this library as a bundle to app/AppKernel.php:

```
public function registerBundles()
{
	$bundles = array(
		// ...
		new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
		new Amisure\P4SApiBundle\AmisureP4SApiBundle()

```

You can then use the p4s.accessor service in your code, for exemple in a Controller to retrieve a list of Organisations:

```
$this->get('p4s.accessor')->findOrganizations(array(
	'organizationType' => UserConstants::SAAD,
	'departementCode' => '94'
));

```

*If you don't want to use this bundle to manage the OAuth authentication, you can by-pass the following steps. But you need to provide the OAuth "access\_token" as a session variable: $this-&gt;session-&gt;get('access\_token').*

To enable the OAuth authentification system, you need to configure this library in your config.yml file:

```
# HWIOAuth
hwi_oauth:
    firewall_name: oauth_secured_area
    http_client:
        timeout:       5 # Time in seconds, after library will shutdown request, by default: 5
        verify_peer:   false # Setting allowing you to turn off SSL verification, by default: true
        ignore_errors: true # Setting allowing you to easier debug request errors, by default: true
        max_redirects: 5 # Number of HTTP redirection request after which library will shutdown request,
                         # by default: 5
    resource_owners:
        p4s.login:
            type:                oauth2
            client_id:           123456abcdef
            client_secret:       apppass1
            access_token_url:    %p4s_path%api/token
            authorization_url:   %p4s_path%api/login
            infos_url:           %p4s_path%api/profile
            scope:               "read"
            user_response_class: HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse
            paths:
                identifier: id
                nickname:   username
                realname:   fullname

```

The parameter %p4s\_path% can be defined defined in parameters.yml and should contain the P4S URL: .

You should also configure your firewall in security.tml

```
security:
    encoders:
        Amisure\P4SApiBundle\Entity\User\SessionUser:
            algorithm:   sha1
            iterations: 1
            encode_as_base64: false

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER, ROLE_BENEFICIARY, ROLE_ORG_USER, ROLE_ORG_ADMIN_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, BENEFICIARY, ROLE_ORG_USER, ROLE_ORG_ADMIN_USER]

    providers:
        chain_provider:
            chain:
                providers: [user_db]
        user_db:
            entity: { class: Amisure\P4SApiBundle\Entity\User\SessionUser, property: username }
        my_custom_hwi_provider:
            id: ib_user.oauth_user_provider

    firewalls:
        oauth_secured_area:
            anonymous: true
            logout: ~
            oauth:
                resource_owners:
                    p4s.login: "/oauth/login/check-p4s"
                login_path: /home
                check_path: /oauth/login
                failure_path: /oauth/login
                oauth_user_provider:
                    service: ib_user.oauth_user_provider

    access_control:
        - { path: ^/home, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/aide, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/oauth/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/oauth/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: IS_AUTHENTICATED_FULLY }

```

Then, you need to complete your routs in your routing.yml file:

```
login_p4s:
    pattern: /oauth/login/check-p4s
logout:
    pattern:   /logout

```

Work in progress
----------------

[](#work-in-progress)

### Current tasks

[](#current-tasks)

- \[███▒ 75%\] Link with the P4S external API - client version
    - Beneficiary: ok v1
    - Organization: ok v1
    - OrganizationUser: ok v1
    - Event: ok v1
    - Evaluation: ok v1
    - LiaisonBook
    - Document
    - Send message
- \[████ 95%\] Link with P4S external API - authentication (using OAuth)
- \[▒▒▒▒ 0%\] Link this library to the future "trialog/php-p4s-api" (Symfony2 unaware)
- \[▒▒▒▒ 5%\] Configure a unit tests engine
- \[▒▒▒▒ 0%\] Add unit tests

### Known bugs

[](#known-bugs)

Si aucune activité n'a eu lieu avec le P4S durant 1h, alors toutes tentatives de connexion du service ou d'appel au P4S (si l'utilisateur est déjà connecté au service) sont vouées à l'échec. La solution consiste à manuellement se déconnecter du P4S (bouton "Déconnexion" en haut à droite sur l'IHM du P4S), puis de reconnecter le service au P4S (bouton "Se connecter via le P4S" sur l'IHM du service)

License
-------

[](#license)

This software is the property of TRIALOG ().

- It is using the Symfony 2 framework under the MIT license. For more information, see the LICENSE\_Symfony2 file.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.4% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~80 days

Total

2

Last Release

4431d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99f39fcb24054f67fc40689bd5647fd393272ec071e16ec0d09fa8264e9d0eb2?d=identicon)[oliviermaridat](/maintainers/oliviermaridat)

---

Top Contributors

[![oliviermaridat](https://avatars.githubusercontent.com/u/953989?v=4)](https://github.com/oliviermaridat "oliviermaridat (27 commits)")[![RafikSM](https://avatars.githubusercontent.com/u/956555?v=4)](https://github.com/RafikSM "RafikSM (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[claroline/core-bundle

Claroline core bundle

165.5k52](/packages/claroline-core-bundle)[anime-db/anime-db

The application for making home collection anime

252.1k2](/packages/anime-db-anime-db)[leaphly/leaphly-sandbox

The Leaphly sandbox

144.4k](/packages/leaphly-leaphly-sandbox)

PHPackages © 2026

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