После submit login формы, редирект не происходить, и выдаются 500 ошибка. Регистрация проходит успешно, user сохраняется в базе, но с ним нельзя залогинится
security.yaml
security:
encoders:
App\Entity\User: bcrypt
providers:
database_users:
entity: { class: App\Entity\User, property: username }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
pattern: ^/
http_basic: ~
form_login:
check_path: security_login
login_path: security_login
csrf_token_generator: security.csrf.token_manager
default_target_path: micro_post_index
logout:
path: security_logout
target: micro_post_index
SecurityController c логин методом
class SecurityController extends AbstractController
{
/**
* @var \Twig_Environment
*/
private $twig;
public function __construct(\Twig_Environment $twig)
{
$this->twig = $twig;
}
/**
* @Route("/login", name="security_login", methods={"GET", "POST"})
*
* @param AuthenticationUtils $authenticationUtils
*/
public function login(AuthenticationUtils $authenticationUtils)
{
return new Response(
$this->twig->render(
'security/login.html.twig',
[
'last_username' => $authenticationUtils->getLastUsername(),
'error' => $authenticationUtils->getLastAuthenticationError()
]
));
}
MicroPostController c index методом
/**
* @Route("/")
*/
class MicroPostController
{
/**
* @Route("/", name="micro_post_index")
*/
public function index()
{
$html = $this->twig->render('micro-post/index.html.twig',
[
'posts' => $this->microPostRepository->findBy([], ['time' => 'DESC'])
]);
return new Response($html);
}
}
login.html.twig
{% extends 'base.html.twig' %}
{% block body %}
{% if error %}
<div class="alert alert-danger">
{{ error.messageKey|trans(error.messageData, 'security') }}
</div>
{% endif %}
<form action="{{ path('security_login') }}" method="post">
<div>
<div class="form-group">
<label class="form-control-label required" for="username">Username</label>
<input type="text" id="username" name="_username" required="required" class="form-control"
value="{{ last_username }}">
</div>
<div class="form-group">
<label class="form-control-label required" for="password">Password</label>
<input type="password" id="password" name="_password" required="required" class="form-control">
</div>
<div class="form-group">
<button type="submit" id="Login" name="Login" class="btn-secondary btn">Login</button>
</div>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
<input type="hidden" name="_target_path" value="{{ app.request.get('redirect_to') }}">
</div>
</form>
{% endblock %}
Debug выдаёт 500
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/admin/Desktop/symfony41-web/symfony4_Project/symfony-01/website_skeleton/src/Entity/User.php on line 193
[Fri Mar 22 18:33:07 2019] 127.0.0.1:62093 [500]: /login - Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/admin/Desktop/symfony41-web/symfony4_Project/symfony-01/website_skeleton/src/Entity/User.php on line 193
Эта строчка кода
/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
{
return $this->serialize([
$this->id,
$this->username,
$this->password
]);
}
191. $this->id,
В чём может быть проблема?
'PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)...
...Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in ...
Что именно здесь не понятно ?
Вам нужно увеличить количество выделяемой памяти для php. Сделайте это в php.ini в директиве memory_limit. memory_limit = 1G и вам хватит :)
Поддерживает ли какой-нибудь orm обновление только изменённых атрибутов объекта? Просто писал свой orm с такой возможностью, но по остальным...