执行时php app/console doctrine:generate:entities etBundle:Users我收到此错误消息:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Doctrine\ORM\Mapping" in class Ampisoft\Bundle\etrackBundle\Entity\Users does not exist, or could not be auto-loaded.
Run Code Online (Sandbox Code Playgroud)
我的实体类如下:
namespace Ampisoft\Bundle\etrackBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM/Entity
* @ORM/Table(name="users")
*/
class Users
{
/**
* @ORM/Column(type="integer")
* @ORM/ID
* @ORM/GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
/**
* @ORM\Column(type="string", length=64)
*/
protected $password;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
/**
* @ORM\Column(type="string", length=60, unique=true)
*/
protected $email;
/** …Run Code Online (Sandbox Code Playgroud) 所以这是用例:
树枝 2.2
交响乐 3.2
在基本模板中,我仅渲染已定义的块(不是“非空”)
{% if block('left_sidebar') is defined %}
<div class="col-md-2">
{{- block('left_sidebar') -}}
</div>
<div class="col-md-10">
{% else %}
<div class="col-md-12">
{% endif %}
Run Code Online (Sandbox Code Playgroud)
为了使上述工作正常,块根本无法定义(这完全是设计的)。无论如何,以下内容都会渲染该块,但我无法弄清楚为什么。
{% if not is_granted('IS_FULLY_AUTHENTICATED') %}
{% block left_sidebar %}
{% include ':blocks:block__login.html.twig' %}
{% endblock %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
我想知道这是否不起作用,因为与基本模板代码起作用的原因相同。也就是说,块在运行时之前编译,条件语句在运行时执行。
任何人都可以确认我是对的吗?或者如果我错了请纠正我?
编辑
我尝试将条件的结果强制为 true 和 false,并且在任何一种情况下都会呈现该块。
我想计算评级系统的平均值,但我在 innodb 中有普通表,在 json 中有一个列,名称为:“评论”,结构如下:
{"comments":
[
{"name": "Jonh", "text": "nice phone", "star": 4},
{"name": "igon", "text": "not good", "star": 2},
{"name": "marco", "text": "i not like this", "star": 3},
{"name": "david", "text": "good product", "stelle": 5}
]
}
Run Code Online (Sandbox Code Playgroud)
现在我需要计算平均星级。它是在 sql 中还是在 php 中?在 sql 中我不知道如何,在 php 中我有查询只提取全明星的问题,例如:
$reviews_nn = $rowprod["reviews"];
$reviews = json_decode($reviews_nn,true);
$max = 0;
$n = 0;
foreach ($reviews[comments][star] as $rate => $count) {
echo 'Seen ', $count, ' ratings of ', $rate, "\n";
$max += $rate …Run Code Online (Sandbox Code Playgroud) I am trying to put a JWT Auth to access my API : /api/docs But I am currently getting an error while trying to get the token with this command :
curl -X POST -H "Content-Type: application/json" http://localhost/login_check -d '{"username":"johndoe","password":"test"}'
Run Code Online (Sandbox Code Playgroud)
Of course I replace username and password
Signature key "/var/www/config/jwt/private.pem" does not exist or is not readable. Did you correctly set the "lexik_jwt_authentication.signature_key" configuration key? (500 Internal Server Error)
security.yaml
firewalls:
login:
pattern: ^/login
stateless: true
anonymous: true
provider: fos_userbundle_2 …Run Code Online (Sandbox Code Playgroud) symfony ×3
php ×2
doctrine ×1
doctrine-orm ×1
jwt ×1
mysql ×1
rating ×1
templating ×1
token ×1
twig ×1