jumpersoft / symfony-base-bundle
Symfony基础包,包含通用类、控件和模板。
Requires
- beberlei/doctrineextensions: ^1.3
- doctrine/doctrine-migrations-bundle: ^3.0
- exercise/htmlpurifier-bundle: ^2.0
- lexik/jwt-authentication-bundle: ^2.12
- nelmio/cors-bundle: ^2.1
- sendgrid/sendgrid: ^7.2
- symfony/google-mailer: 5.4.*
- symfony/mailer: 5.4.*
- twig/twig: ^2.12|^3.0
- dev-master
- 3.0.1
- 3.0.0
- 2.5.7
- 2.5.6
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.3
- 2.4.2
- 2.4.1
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.60
- 1.0.59
- 1.0.58
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-09-15 01:42:36 UTC
README
步骤 1:下载Bundle
打开命令行控制台,进入您的项目目录,并执行以下命令以下载此Bundle的最新稳定版本
$ composer require jumpersoft/symfony-base-bundle
此命令需要您已全局安装Composer,如Composer文档中的安装章节中所述。
步骤 2:启用Bundle
然后,通过将其添加到项目中app/AppKernel.php文件中注册的Bundle列表中来启用Bundle
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Jumpersoft\BaseBundle\JumpersoftBaseBundle(),
);
// ...
}
// ...
}
步骤 3:配置Bundle
在"app/config/parameters.yml"和".."parameters.yml.dist"中设置配置,
基础参数,将所有具有可选值的参数放入每个工具中
# 秘密api captcha密钥(如google recaptcha) jumpersoft.recaptcha.secretCaptchaKey: ''
# 用于身份验证工具的示例,例如'MyBundleBundle:User'或'JumpersoftEcommerceBundle:User' jumpersoft.entityUser: ''
# 身份验证失败时重定向的路线 jumpersoft.redirectToOnAuthenticationFailure: ''
# 用于与JumpersoftEcommerceBundle一起使用的默认商店ID jscommerce.defaultStoreId: ''
# 用于无回复通知的电子邮件 mailer_email_no_reply: 'info@jumpersoft.com'
# 用于与JumpersoftEcommerceBundle通知一起使用的电子邮件 mailer_email_intern_for_notifications: 'webadmin@jumpersoft.com'
服务参数,将此配置添加到您的services.yml主文件中
services
... _defaults: bind: $defaultStoreId: '%jscommerce.defaultStoreId%' $debug: '%kernel.debug%'安全参数,您可以更改您的名称
jumpersoft.security.token_key: '' # csrf token jumpersoft.security.jwt_private_key_path: '' # ssh路径私钥路径 jumpersoft.security.jwt_public_key_path: '' # ssh路径公钥路径 jumpersoft.security.jwt_key_pass_phrase: '' # ssh密钥密码短语 jumpersoft.security.jwt_token_ttl: 86400 # jwt持续时间
在"app/config/config.yml"中设置下一个lex jwt身份验证配置
添加以下配置以用于异常监听器
framework
... templating: engines: ['twig']可选,添加以下配置以添加对DQL中实体的快捷访问
doctrine: ...
orm: .. mappings: MainEntities: type: annotation # Changue to your bundle name dir: '%kernel.project_dir%/src/AppBundle/Entity' prefix: AppBundle\Entity alias: E添加Lexit JWT身份验证配置
lexik_jwt_authentication
private_key_path: %jumpersoft.security.jwt_private_key_path% public_key_path: %jumpersoft.security.jwt_public_key_path% pass_phrase: %jumpersoft.security.jwt_key_pass_phrase% token_ttl: %jumpersoft.security.jwt_token_ttl%
步骤 4:使用Bundle
与该Bundle相关的主题
模板
- 控件:文本、组合、单选和其他相关输入控件,如与jQuery和Bootstrap控件(如select2、datetimepicker等)相关的更复杂控件。
- 表单:通用表单,如用户登录、用户注册、地址等。
类
- JumpersoftBaseController:用于多种目的的Controller symfony类的扩展。
- JwtAuthenticator:用于身份验证和授权的类,使用"GuardAuthenticator"。
扩展
- JumpersoftMailerExtension:用于多种目的的Mailer扩展。
- JumpersoftMapArrayExtension:用于从json请求映射数组、对类验证器-regex进行验证等的功能。
- JumpersoftReCaptchaExtension:用于处理captcha功能的功能。
- JwtAuthenticator:处理Json Web Token身份验证的类。
注解
- CsrfTokenValidation:用于在控制器中处理CSRF功能的注解。
Twig扩展
- JumpersoftBaseTwigExtension:用于在"America/Mexico_City"时区中处理格式化日期的通用函数。
MySQL的Doctrine扩展
- 字符串函数:FORMAT
- 日期时间函数:DATE_FORMAT
步骤 5:注意
我们建议使用"nelmio/cors-bundle": "~1.4"的Bundle,以充分利用json web tokens的所有优点。