teknoo / east-common
通用包,遵循#East编程哲学,基于Teknoo/East-Foundation(以及Teknoo/Recipe)构建,提供组件(用户管理、对象持久性、模板渲染等),用于创建Web应用或网站。
Requires
- php: ^8.2
- php-di/php-di: ^7.0.6
- teknoo/east-foundation: ^7.7
- teknoo/immutable: ^3.0.17
- teknoo/recipe: ^5.1
- teknoo/states: ^6.3
Requires (Dev)
- ext-mongodb: *
- ext-tidy: *
- behat/behat: ^3.13
- doctrine/common: ^3.4.3
- doctrine/mongodb-odm: ^2.6.2
- doctrine/mongodb-odm-bundle: ^4.7||^5
- doctrine/persistence: ^3.2
- knpuniversity/oauth2-client-bundle: ^2.18
- laminas/laminas-diactoros: ^3.3
- league/flysystem: ^3.23
- league/oauth2-client: ^2.7
- matthiasmullie/minify: ^1.3.71
- phpstan/extension-installer: ^1.3.1
- phpstan/phpstan: ^1.10.63
- phpunit/phpunit: ^11.2.1
- roave/security-advisories: dev-latest
- scheb/2fa-backup-code: ^6.12||^7
- scheb/2fa-bundle: ^6.12||^7
- scheb/2fa-google-authenticator: ^6.12||^7
- scheb/2fa-totp: ^6.12||^7
- spomky-labs/otphp: ^11.2
- squizlabs/php_codesniffer: ^3.8
- symfony/config: ^6.3||^7
- symfony/console: ^6.3||^7
- symfony/dependency-injection: ^6.3||^7
- symfony/expression-language: ^6.3||^7
- symfony/form: ^6.3||^7
- symfony/http-kernel: ^6.3||^7
- symfony/mailer: ^6.3||^7
- symfony/mime: ^6.3||^7
- symfony/notifier: ^6.3||^7
- symfony/password-hasher: ^6.3||^7
- symfony/property-access: ^6.3||^7.0
- symfony/psr-http-message-bridge: ^2.3.1||^6.4||^7
- symfony/routing: ^6.3||^7
- symfony/security-bundle: ^6.3||^7
- symfony/security-core: ^6.3||^7
- symfony/security-http: ^6.3||^7
- symfony/validator: ^6.3||^7
- teknoo/bridge-phpdi-symfony: ^6.0.4
- twig/cssinliner-extra: ^3.8
- twig/inky-extra: ^3.8
- twig/twig: ^3.8
- dev-master
- 2.12.4
- 2.12.3
- 2.12.2
- 2.12.1
- 2.12.0
- 2.11.0
- 2.10.1
- 2.10.0
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.0
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.4.0-beta2
- 2.4.0-beta1
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 2.0.0-beta1
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
This package is auto-updated.
Last update: 2024-09-22 10:18:46 UTC
README
通用包,遵循#East编程哲学,基于Teknoo/East-Foundation(以及Teknoo/Recipe)构建,并提供组件(用户管理、对象持久性、模板渲染等),用于创建Web应用或网站。
此项目是从East Website分支出来的,目的是将CMS(管理、前端和翻译)以及所有其他有助于构建网站或Web应用的基组件(对象持久性和CRUD操作、模板渲染、用户管理和认证)分离。
使用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/Resources/config/di.php' - '%kernel.project_dir%/vendor/teknoo/east-foundation/infrastructures/symfony/Resources/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/Resources/config/di.php' - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/symfony/Resources/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/Resources/config/admin_routing.yaml' prefix: '/admin' common: resource: '@TeknooEastCommonBundle/Resources/config/routing.yaml'
启用第三方OAuth2提供者进行认证(以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 <?php declare(strict_types=1); namespace App\Security\Authenticator; use DomainException; use League\OAuth2\Client\Provider\ResourceOwnerInterface; use Omines\OAuth2\Client\Provider\GitlabResourceOwner; use Teknoo\East\Common\Object\User; use Teknoo\East\CommonBundle\Contracts\Security\Authenticator\UserConverterInterface; use Teknoo\Recipe\Promise\PromiseInterface; class UserConverter implements UserConverterInterface { public function extractEmail(ResourceOwnerInterface $owner, PromiseInterface $promise): UserConverterInterface { if (!$owner instanceof GitlabResourceOwner) { $promise->fail(new DomainException('Resource not manager')); return $this; } $promise->success($owner->getEmail()); return $this; } public function convertToUser(ResourceOwnerInterface $owner, PromiseInterface $promise): UserConverterInterface { if (!$owner instanceof GitlabResourceOwner) { $promise->fail(new DomainException('Resource not manager')); return $this; } $promise->success( (new User())->setEmail($owner->getEmail()) ->setLastName($owner->getName()) ->setFirstName($owner->getUsername()) ); return $this; } }
//In routes/gitlab.yaml admin_connect_gitlab_login: path: '/oauth2/gitlab/login' defaults: _controller: 'Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint' admin_connect_gitlab_check: path: '/oauth2/gitlab/check' defaults: _controller: 'teknoo.east.common.endpoint.static' template: '@@TeknooEastCommon/Admin/index.html.twig' errorTemplate: '@@TeknooEastCommon/Error/404.html.twig' _oauth_client_key: gitlab
//In your template, create a link with {{ path('admin_connect_gitlab_login') }}
支持此项目
此项目免费且将保持免费。它完全由EIRL的活动支持。如果您喜欢它并帮助我维护和改进它,请通过Patreon或Github支持我。
谢谢 :) Richard.
致谢
EIRL Richard Déloge - https://deloge.io - 首席开发者。Teknoo Software SASU - https://teknoo.software
关于Teknoo Software
Teknoo Software 是一家PHP软件编辑公司,由Richard Déloge创立,作为EIRL Richard Déloge的一部分。Teknoo Software的目标:为我们的合作伙伴和社区提供一系列高质量的服务或软件,分享知识和技能。
许可证
East Common遵循MIT许可证 - 请参阅许可证文件夹以获取详细信息。
安装与要求
要使用composer安装此库,请运行此命令
composer require teknoo/east-common
使用Symfony启动项目
symfony new your_project_name new
composer require teknoo/composer-install
composer require teknoo/east-common-symfony
此库需要
* PHP 8.1+
* A PHP autoloader (Composer is recommended)
* Teknoo/Immutable.
* Teknoo/States.
* Teknoo/Recipe.
* Teknoo/East-Foundation.
* Optional: Symfony 6.3+ (for administration)
来自Teknoo Common的新闻
此库需要PHP 8.1或更高版本,并且仅与Symfony 6.0或更高版本兼容。
- 支持Recipe 4.1.1+
- 支持East Foundation 6.0.1+
- 公共常量是最终的
- 块的类型是枚举
- 方向是枚举
- 在不可变对象上使用只读属性行为
- 移除对在Symfony 6.0中删除的已弃用功能的支持(Salt、LegacyUser)
- 对于可调用,使用(...)表示法代替数组表示法
- 在前端端点启用纤维支持
- 已将
QueryInterface
拆分为QueryElementInterface
和QueryCollectionInterface
,以区分仅获取单个元素或标量值的查询以及针对对象集合的查询。 LoaderInterface::query
方法仅用于QueryCollectionInterface
查询。- 为
QueryElementInterface
查询添加了一个新的方法LoaderInterface::fetch
。
- 警告*:此版本不再支持所有旧版用户。用户盐也不受支持,所有用户密码必须在切换到此版本之前进行转换。
贡献:)
欢迎使用对此项目的贡献。 在Github上分支它