PHPackages                             teknoo/east-common - 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. [Framework](/categories/framework)
4. /
5. teknoo/east-common

ActiveLibrary[Framework](/categories/framework)

teknoo/east-common
==================

Universal package, following the #East programming philosophy, build on Teknoo/East-Foundation (and Teknoo/Recipe), providing components (user management, object persistence, template rendering, ..) for the creation of web application or website.

4.3.0(1mo ago)214.0k↑29.4%14BSD-3-ClausePHPPHP ^8.4

Since Apr 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/TeknooSoftware/east-common)[ Packagist](https://packagist.org/packages/teknoo/east-common)[ Docs](https://teknoo.software/east-collection/common)[ GitHub Sponsors](https://github.com/sponsors/TeknooSoftware)[ Patreon](https://www.patreon.com/teknoo_software)[ RSS](/packages/teknoo-east-common/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (126)Versions (117)Used By (4)

Teknoo Software - Common library
================================

[](#teknoo-software---common-library)

[![Latest Stable Version](https://camo.githubusercontent.com/dcaa7a52082c164394c669c7e1c8d8cafef574ff5e48c339f8a737fbb3afa83a/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f656173742d636f6d6d6f6e2f762f737461626c65)](https://packagist.org/packages/teknoo/east-common)[![Latest Unstable Version](https://camo.githubusercontent.com/dcb3681b31a7898fb32c78f8ac9483dde3ee8247bd7713e53c795c57018129c1/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f656173742d636f6d6d6f6e2f762f756e737461626c65)](https://packagist.org/packages/teknoo/east-common)[![Total Downloads](https://camo.githubusercontent.com/96deea5dbc0b475fd879f09558e85d0c34e61618af146445de1a531b92cbf2a9/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f656173742d636f6d6d6f6e2f646f776e6c6f616473)](https://packagist.org/packages/teknoo/east-common)[![License](https://camo.githubusercontent.com/7da330966e13cd58e8507fb8ce6780e0b0c3c691439cca28ee302e17ee06a881/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f656173742d636f6d6d6f6e2f6c6963656e7365)](https://packagist.org/packages/teknoo/east-common)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

Universal package, following the #East programming philosophy, build on Teknoo/East-Foundation (and Teknoo/Recipe), and providing components (user management, object persistence, template rendering, ..) for the creation of web application or website.

This project is a fork of `East Website` to separate the CMS (admin, front and translation) and all others base components helpful to build a website or a webapp (objet persistence and CRUD operations, template rendering, user management and authentification).

Example with Symfony
--------------------

[](#example-with-symfony)

```
#These operations are not required with teknoo/east-common-symfony

#config/packages/di_bridge.yaml:
di_bridge:
    compilation_path: '%kernel.project_dir%/var/cache/phpdi'
    definitions:
      - '%kernel.project_dir%/config/di.php'

#config/packages/east_foundation.yaml:
di_bridge:
    definitions:
        - '%kernel.project_dir%/vendor/teknoo/east-foundation/src/di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-foundation/infrastructures/symfony/config/di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-foundation/infrastructures/symfony/config/laminas_di.php'
    import:
        Psr\Log\LoggerInterface: 'logger'

#config/packages/east_common_di.yaml:
di_bridge:
    definitions:
        - '%kernel.project_dir%/vendor/teknoo/east-common/src/di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/symfony/config/di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/symfony/config/laminas_di.php'
        - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/di.php'
    import:
        Doctrine\Persistence\ObjectManager: 'doctrine_mongodb.odm.default_document_manager'

#bundles.php
...
Teknoo\DI\SymfonyBridge\DIBridgeBundle::class => ['all' => true],
Teknoo\East\FoundationBundle\EastFoundationBundle::class => ['all' => true],
Teknoo\East\CommonBundle\TeknooEastCommonBundle::class => ['all' => true],

#In doctrine config (east_common_doctrine_mongodb.yaml)
doctrine_mongodb:
    document_managers:
        default:
            auto_mapping: true
            mappings:
                TeknooEastCommon:
                    type: 'xml'
                    dir: '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/config/universal'
                    is_bundle: false
                    prefix: 'Teknoo\East\Common\Object'
                TeknooEastCommonDoctrine:
                    type: 'xml'
                    dir: '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/config/doctrine'
                    is_bundle: false
                    prefix: 'Teknoo\East\Common\Doctrine\Object'

#In security.yaml
security:
    #...
    providers:
        with_password:
            id: 'Teknoo\East\CommonBundle\Provider\PasswordAuthenticatedUserProvider'

    password_hashers:
        Teknoo\East\CommonBundle\Object\PasswordAuthenticatedUser:
            algorithm: '%teknoo.east.common.bundle.password_authenticated_user_provider.default_algo%'

#In routes/common.yaml
admin_common:
    resource: '@TeknooEastCommonBundle/config/admin_routing.yaml'
    prefix: '/admin'

common:
    resource: '@TeknooEastCommonBundle/config/routing.yaml'
```

Enable third party authentication with an OAuth2 Provider (example with Gitlab)
-------------------------------------------------------------------------------

[](#enable-third-party-authentication-with-an-oauth2-provider-example-with-gitlab)

```
//In security.yaml
security:
    providers:
        //...
        # Third party user provider
        from_third_party:
            id: 'Teknoo\East\CommonBundle\Provider\ThirdPartyAuthenticatedUserProvider'
    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        //...
        admin_gitlab_login:
            pattern: '^/oauth2/gitlab/login$'
            security: false

        #require admin role for all others pages
        restricted_area:
            //...
            # Enable oauth2 authenticator for this form
            custom_authenticators:
                - '%teknoo.east.common.bundle.security.authenticator.oauth2.class%'

//In knpu_oauth2_client.yaml
knpu_oauth2_client:
    clients:
        # will create service: "knpu.oauth2.client.gitlab"
        # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\GitlabClient
        # composer require omines/oauth2-gitlab
        gitlab:
            # must be "gitlab" - it activates that type!
            type: gitlab
            # add and set these environment variables in your .env files
            client_id: '%env(OAUTH_GITLAB_CLIENT_ID)%'
            client_secret: '%env(OAUTH_GITLAB_CLIENT_SECRET)%'
            # a route name you'll create
            redirect_route: admin_connect_gitlab_check
            redirect_params: {}
            # Base installation URL, modify this for self-hosted instances
            domain: '%env(OAUTH_GITLAB_URL)%'

//In service.yaml
services:
    Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint:
        class: 'Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint'
        arguments:
          - '@KnpU\OAuth2ClientBundle\Client\ClientRegistry'
          - 'gitlab'
          - ['read_user']
        calls:
          - ['setResponseFactory', ['@Psr\Http\Message\ResponseFactoryInterface']]
          - ['setRouter', ['@router']]
        public: true

    Teknoo\East\CommonBundle\Contracts\Security\Authenticator\UserConverterInterface:
        class: 'App\Security\Authenticator\UserConverter'
```

```
//In src/Security\Authenticator\UserConverter.php
