我已将FOSRestBundle配置如下:
#FOSRestBundle
fos_rest:
param_fetcher_listener: true
body_listener: true
format_listener:
rules:
- { path: ^/, priorities: [ json, html ], fallback_format: ~, prefer_extension: true }
media_type:
version_regex: '/(v|version)=(?P<version>[0-9\.]+)/'
body_converter:
enabled: true
validate: true
view:
mime_types:
json: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']
view_response_listener: 'force'
formats:
xml: false
json: true
templating_formats:
html: true
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
messages:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
allowed_methods_listener: true
access_denied_listener:
json: true
Run Code Online (Sandbox Code Playgroud)
我在控制器上有这个:
namespace PDI\PDOneBundle\Controller\Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\Get;
class RepresentativeRestController extends FOSRestController
{
/**
* Get …Run Code Online (Sandbox Code Playgroud) 我不是GIT专家所以我需要一些帮助来完成我正在进行的项目的设置.所以基本上这就是我需要的:
git pull一直使用Github主项目的最新变化来更新CORE?我使用SmartGit作为主客户端,但也有git命令行.
对此有何帮助?
我在从SF2.0.x迁移到SF2.7的应用程序中收到此错误:
[1] Symfony\Component\Debug\Exception\FatalErrorException: Compile Error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
at n/a
in /var/www/html/reptooln_admin/app/cache/dev/twig/68/7f/63589dd3687cb849dd68e6b6c10aa99eda1d82f95a5f3ac52a864d200499.php line 39
Run Code Online (Sandbox Code Playgroud)
我不知道什么是失败或如何解决这个问题所以我需要一些建议.这是报告Stacktrace的缓存文件中的行:
if ((((empty((isset($context["form_action"]) ? $context["form_action"] : $this->getContext($context, "form_action"))) == true) || (isnull((isset($context["form_action"]) ? $context["form_action"] : $this->getContext($context, "form_action"))) == true)) || (isset((isset($context["form_action"]) ? $context["form_action"] : $this->getContext($context, "form_action"))) == false))) {
echo " ";
$context["form_action"] = "";
echo " ";
Run Code Online (Sandbox Code Playgroud)
我有这个TwigExtension:
class PDOneTwigExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
'var_dump' => new …Run Code Online (Sandbox Code Playgroud) 我有一个GIT存储库,有两个分支master和entidades.我需要合并master从entidades分支分支一些东西.看一看图像,标志着该文件夹EntityBundle是我需要从合并的唯一的事情entidades来master,我该怎么办?我entidades在SmartGit的分支上点击合并,并得到一个像图像显示的消息,但在这里我迷路了,因为我不知道什么是正确的选择,以便没有弄乱master回购,可以给我一个提示?

**我的工具中的图表表示**

我正在开发一个简单的CRUD来管理我正在工作的应用程序的用户/角色/组.管理我正在使用的用户FOSUserBundle.我想做的事可以通过以下几种方式完成:
但我不知道怎么做.我知道FOSUser BaseUser类已经有了一个列,roles并且在FOSUser 的文档中解释了如何ManyToMany在用户和组之间建立关系,但是没有谈论任何关于角色的内容.想到的唯一想法是创建一个实体来管理角色以及一个用于相同目的的表单,如下所示:
角色实体
use Symfony\Component\Security\Core\Role\RoleInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="fos_role")
* @ORM\Entity(repositoryClass="UserBundle\Entity\Repository\RoleRepository")
*
* @see User
* @see \UserBundle\Role\RoleHierarchy
*
*/
class Role implements RoleInterface
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="name", type="string", length=80, unique=true)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity="Role", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true)
* @var Role[]
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="Role", …Run Code Online (Sandbox Code Playgroud) 我有这个功能:
/**
* @Secure(roles="IS_AUTHENTICATED_FULLY")
* @Route("/chequearFabricanteDistribuidor", name="chequearFabricanteDistribuidor", condition="request.headers.get('X-Requested-With') == 'XMLHttpRequest'")
* @Method("GET")
*/
public function chequearFabricanteAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('AppBundle:FabricanteDistribuidor')->findOneBy(
array( 'nombre' => $request->query->get('fabricante')['nombre'] )
);
$response['valid'] = true;
if ($entities) {
$response['valid'] = false;
}
return new JsonResponse($response);
}
Run Code Online (Sandbox Code Playgroud)
需要从两种不同的形式调用该函数,唯一不同的是保存该值的请求var.在第一种形式是:$request->query->get('fabricante')['nombre']而在第二种形式是,$request->query->get('distribuidor')['nombre']所以我问是否正确的方法来处理这个问题可能是:
if (isset($request->query->get('fabricante')))
{
$nombre = $request->query->get('fabricante')['nombre'];
}
else
{
$nombre = $request->query->get('distribuidor')['nombre'];
}
Run Code Online (Sandbox Code Playgroud)
这是正确的吗?存在更好的一个?
我从头开始创建了一个rails应用程序(Rails 4.1.0),我遇到了一个我无法解决的问题.我已经安装并配置了Apache Passenger Module,它工作正常.每当我尝试访问虚拟主机时,都会收到错误500:
Missing secret_key_base for 'production' environment, set this value in config/secrets.yml
Run Code Online (Sandbox Code Playgroud)
secret.yml文件包含以下配置:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Run Code Online (Sandbox Code Playgroud)
即使我不建议我这样做:
production:
secret_key_base: XXXXXXXXXXXXXXXXXXXXXXXXXXXX (random key)
Run Code Online (Sandbox Code Playgroud)
但Apache日志显示:
# tailf /etc/httpd/logs/error_log
[Tue May 06 12:56:18 2014] [error] [client 192.168.3.1] Premature end of script headers:
App 4405 stderr: [ 2014-05-06 12:56:18.5763 4421/0x9d48bdc(Worker 1) utils.rb:68 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 4421, thread 0x9d48bdc(Worker 1)):
App 4405 stderr: from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:440:in `validate_secret_key_config!' …Run Code Online (Sandbox Code Playgroud) 我不知道这是Symfony问题还是FOSUserBundle问题所以我会在这里报告并希望得到一些帮助.我有两个开发实例:
CentOS 6.5, PHP 5.5.16, MySQL 5.5.37
CentOS 7, PHP 5.6.0, MariaDB 5.5.37
Run Code Online (Sandbox Code Playgroud)
我在两个实例和同一个项目中尝试了相同的项目我的意思相同:没有任何供应商复制,并且在两个实例中都首先运行"composer update".在作曲家更新供应商后,我试图访问管理区域,由FOSUserBundle处理并在第一个实例中出错,它没有任何问题,但在第二个它不起作用,我得到这个错误:
错误!警告:在/var/www/html/tanane/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php第872行中反序列化"Tanane\UserBundle\Entity\User"的错误数据格式
有人可以给我一些建议吗?是Symfony错误还是FOSUserBundle错误?或者它是另一回事,我没有看到它?
如果用户在10分钟内不执行任何操作,我已将应用程序配置为在超时时关闭会话.在config.yml我有这样的:
session:
handler_id: ~
cookie_lifetime: 600 # 10 minutes
gc_maxlifetime: 600 # 10 minutes
gc_probability: 1
gc_divisor: 1
Run Code Online (Sandbox Code Playgroud)
我每隔一分钟进行一次Ajax调用,以检查会话是否即将到期或不会过期,这是我检查的内容:
public function isLoggedInAction(Request $request)
{
$response = array();
$response['authenticated'] = FALSE;
$status = 200;
$securityContext = $this->container->get('security.context');
if ($securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
$response['authenticated'] = TRUE;
}
return new JsonResponse($response, $status ?: 200);
}
Run Code Online (Sandbox Code Playgroud)
由于一些不知情的原因不起作用,每10分钟会话都关闭,无论我是在使用页面还是不在,为什么?我错过了什么?
编辑1尝试新值,仍然无效:
session:
handler_id: ~
cookie_lifetime: 1800
gc_maxlifetime: 600
gc_probability: 1
gc_divisor: 100
Run Code Online (Sandbox Code Playgroud)
当我在页面上工作,执行Ajax调用和一些其他任务时,会话已关闭,因此无法正常工作.显然对我来说唯一有用的价值就是设置cookie_lifetime: 86400 #1 day,这对我来说很疯狂!
编辑2在 …
php ×6
symfony ×6
git ×3
smartgit ×2
ajax ×1
bitbucket ×1
github ×1
heroku ×1
json ×1
merge ×1
patch ×1
ruby ×1
session ×1
symfony-2.5 ×1
symfony-2.6 ×1
symfony-2.7 ×1
twig ×1
user-roles ×1
usergroups ×1