我有以下场景:
现在,当我在github上浏览打开的PR时,存储库部分显示"未知存储库".
我想恢复我的分叉,以使此部分显示其名称.
我的第一个想法是重新分配上游存储库,正确地重新设置它(感谢这个)并祈祷该github自动重新填充PR中的正确名称.
不幸的是,没有发生任
我怎样才能做到这一点?
我应该联系支持吗?
我使用SensioLabs Insight来控制我的代码质量.
对于简单的文件上传,我必须获取上传目录的绝对路径:
protected function getUploadRootDir()
{
// the absolute directory path where uploaded
return __DIR__.'/../../../../web/'.$this->getUploadDir();
}
Run Code Online (Sandbox Code Playgroud)
代码直接来自官方文档(如何使用Doctrine处理文件上传)
但SLInsight提出了一个警告,如果分析的代码中包含__DIR__或__FILE__PHP魔术常量:
__DIR__和__FILE__常量可能与Symfony资源覆盖系统冲突.
如何使用这些常量会导致与Symfony冲突?
我怎样才能在代码中避免它们?
我使用以下代码片段与ajax远程添加一个新的select2标签,我想在新标签/删除标签事件上注册或删除我的多对多表的一些记录
表看起来像
---------------------------------
+--voucher_id--+|+--product_id--+
---------------------------------
+ 123 | 566 +
---------------------------------
+ 156 | 566 +
---------------------------------
+ 123 | 426 +
---------------------------------
+ 156 | 516 +
---------------------------------
Run Code Online (Sandbox Code Playgroud)
我的Javascript
$(".e6").select2({
tags: true,
placeholder: 'placeholder',
minimumInputLength: 1,
ajax: {
url: 'searchProducts',
dataType: 'json',
data: function(term) {
return {q: term};
},
results: function(data) {
return {results: data};
}
},
createSearchChoice: function(term, data) {
if ($(data).filter(function() {
return this.computername.localeCompare(term) === 0;
}).length === 0) {
return {id: term, name: term}; …Run Code Online (Sandbox Code Playgroud) 我使用LexikJWTBundle作为RESTful API.
登录工作正常,我得到我的令牌.但是当我发出GET请求时,我得到一个没有内容的401.Authorization标题似乎没问题,因为我在分析器中得到了这个:Request Headers:authorization:Bearer {token} Request Server参数:HTTP_AUTHORIZATION:Bearer {token}
我得到的401来自:https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Security/Firewall/JWTListener.php#L80
我尝试了不同的解决方案,但仍然无法正常工作.
你对如何解决/调试这个有什么想法吗?
我的配置:
# config.yml
...
lexik_jwt_authentication:
private_key_path: %kernel.root_dir%/var/jwt/private.pem # ssh private key path
public_key_path: %kernel.root_dir%/var/jwt/public.pem # ssh public key path
pass_phrase: 'TEST' # ssh key pass phrase
token_ttl: 86400 # token ttl - defaults to 86400
Run Code Online (Sandbox Code Playgroud)
和
# security.yml
security:
role_hierarchy:
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_SONATA_ADMIN, ROLE_ALLOWED_TO_SWITCH]
# http://sonata-project.org/bundles/admin/2-3/doc/reference/security.html
# set access_strategy to unanimous, else you may have unexpected behaviors
access_decision_manager:
strategy: unanimous
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: …Run Code Online (Sandbox Code Playgroud) 我经历了很多stackoveflow问题和文章,但找不到合适的答案.
我正在使用fosuserbundle,hwiouthbundle和lexikjwt bundle.
我正在开发一个基于symfony的api,它将由Android应用程序和角度应用程序使用.
现在我需要注册和登录系统fosuserbundle facebook登录hwiouthbundle和api保护lexikjwt捆绑.
我已经实现了fosuserbundle和hwiouthbundke,两者都没有编写用户控制器.但我需要休息而不是形式.但我无法输入:在路由器中休息.
现在我如何登录,用fosuserbundle注册用户休息?我不想使用fosouth服务器.只需要注册和登录api而不是从网上休息.
我正在尝试在数据库中的两个实体之间设置 FK。父表与子表具有多对一关系。我无法使用正常的parent_id => id FK 连接这些表,因为子表是由外部进程填充的(父表永远不知道子表的主ID)。
Doctrine 接受如下所示的实体,但 Mysql 在尝试将 FK 添加到表时失败,并出现以下错误。
ALTER TABLE parent_tbl ADD CONSTRAINT FK_1172A832F85E0677 FOREIGN KEY (username) REFERENCES child_tbl (username);
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`dmname`.`#sql-f16_d8acf`, CONSTRAINT `FK_1172A832F85E0677` FOREIGN KEY (`username`) REFERENCES `child_tbl` (`username`))
class Parent
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Child")
* @ORM\JoinColumn(name="username", referencedColumnName="username", nullable=false)
*/
protected $username;
// ...
}
class Child
{
/** …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的Symfony 2.7应用程序上使用LexikJWTAuthenticationBundle和FOSUserBundle.
基本上,FOSUserBundle配置工作正常:我正确加载我的灯具,如果我尝试通过登录表单登录它成功.
从login_check获取令牌也有效.然后我在头文件中放置了带有"Bearer"的Authorization标头,并尝试访问另一个页面.它总是会产生401响应.
谁有任何关于可能是什么问题或如何进行调试的线索?
这是我的配置:
# app/config/config.yml
# DunglasJsonLdApi
dunglas_json_ld_api:
title: %api_name%
description: %api_description%
default:
order: DESC
# FOSUserBundle
fos_user:
db_driver: orm
firewall_name: api
user_class: ApiBundle\Bundles\UserBundle\Entity\User
# LewikJWTAuthentificationBundle
lexik_jwt_authentication:
private_key_path: %kernel.root_dir%/config/jwt/private.pem
public_key_path: %kernel.root_dir%/config/jwt/public.pem
pass_phrase: %jwt_pass_phrase%
token_ttl: 86400
Run Code Online (Sandbox Code Playgroud)
# app/config/routing.yml
# DunglasJsonLdBundle
api_doc:
resource: @DunglasJsonLdApiBundle/Resources/config/routing.xml
prefix: /api
api:
resource: .
type: json-ld
prefix: /api
# FOSUserBundle
fos_user_security_login:
path: /login
defaults: { _controller: FOSUserBundle:Security:login }
fos_user_security_check:
path: /api/login_check
defaults: { _controller: FOSUserBundle:Security:check }
fos_user_security_logout:
path: /logout
defaults: …Run Code Online (Sandbox Code Playgroud) 我正在为奏鸣曲/出口商做出贡献,这是一个用于以多种格式(CSV、JSON、XML、XLS 等)导出数据的库。
我在一个 Writer 上工作,它通过封装另一个 Writer(如 CsvWriter 或 XlsWriter)将布尔值转换为字符串(例如是/否)。
这是我第一次使用 phpunit。
在现有 Writer 上进行的所有单元测试都使用此逻辑:
- 创建一个文件。
- 使用相应的格式将数据写入文件。
- 做一个 assertEqualsfile_get_contents(filename)。
所以,我写了这个测试:
public function setUp()
{
$this->filename = 'formatedbool.xls';
$this->sampleWriter = new XlsWriter($this->filename, false);
$this->trueLabel = 'oui';
$this->falseLabel = 'non';
if (is_file($this->filename)) {
unlink($this->filename);
}
}
public function testValidDataFormat()
{
$writer = new FormatedBoolWriter($this->sampleWriter, $this->trueLabel, $this->falseLabel);
$writer->open();
$writer->write(array('john', 'doe', false, true));
$writer->close();
$expected = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name=ProgId content=Excel.Sheet><meta name=Generator content="https://github.com/sonata-project/exporter"></head><body><table><tr><td>john</td><td>doe</td><td>non</td><td>oui</td></tr></table></body></html>';
$this->assertEquals($expected, trim(file_get_contents($this->filename))); …Run Code Online (Sandbox Code Playgroud) 我见过类似的问题,但仍然无法使其发挥作用.
我是Symfony的新手,我正在使用Lexik JWT捆绑包和symfony3进行API身份验证,以及一个用于Web身份验证的登录表单.
我得到令牌确定,但当我尝试使用它时,我得到401 - 身份验证不良.我读过它可能是一个apache问题所以我正在尝试使用PHP的内置Web服务器,但仍然没有运气.
这是我的security.yml文件:
security:
encoders:
AppBundle\Entity\User:
algorithm: bcrypt
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
in_memory:
memory: ~
our_db_provider:
entity:
class: AppBundle:User
property: username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
provider: our_db_provider
api:
pattern: ^/api
stateless: true
provider: our_db_provider
lexik_jwt:
authorization_header: # check token in Authorization Header
enabled: true
prefix: …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来复制git commit -S除了特定提交之外的内容,例如通过提供其 SHA。
是否可以?
symfony ×7
jwt ×3
php ×3
git ×2
github ×2
ajax ×1
doctrine ×1
doctrine-orm ×1
jquery ×1
phpunit ×1
pull-request ×1
sonata ×1
symfony-2.7 ×1
unit-testing ×1