74,212 questions
0
votes
0
answers
56
views
How to install league/csv bundle with Doctrine v3.3 on Symfony?
I am having a problem today installing the league/csv bundle (v9.27) on my Symfony (v7.2) project with doctrine/orm (v3.3)! When I run command php require league/csv, I get this message:
Your ...
69
votes
1
answer
15k
views
What does ~ mean in the YML configuration file in Symfony 2?
What does ~ mean in the YML configuration file in Symfony 2?
For example:
NotBlank: ~
1
vote
3
answers
9k
views
How do I avoid escaping HTML tags so they display as markup?
I have a variable in PHP $var="<b>#Something#</b>"; and render it via Twig like {{ var }}.
I don't want it to render <b>#Something#</b>, but as #Something#. Where am ...
7
votes
5
answers
11k
views
Validate enum type with [#Assert\Choice]
I'm trying to validate enum type inside a custom DTO class. I'm trying to use the Symfony #[Assert\Choice] attribute but it seems that it doesn't work if I pass wrong value.
Custom DTO:
#[Assert\...
4
votes
1
answer
11k
views
How to mapping type ENUMS in Doctrine?
I am using PHP 8.1.6, Symfony 6 with Doctrine ORM. I've been trying to get it to work for a long time but with no luck. I have followed tutorials but they are usually from other older versions of ...
1
vote
1
answer
1k
views
Symfony security access_control - multiple roles with AND operator
Is it possible to assign required roles for route, where all of the roles are mandatory for granted access? Currently I have something like this:
security:
access_control:
- { path: ^/...
0
votes
2
answers
896
views
Symfony Entity on first save
In Symfony using doctrine, whats the best way to run a certain function just before an entity is saved/persisted to the database. I only want it to be run once in its lifetime so I guess the ...
22
votes
8
answers
38k
views
symfony : can't we have a hidden entity field?
I am rendering a form with an entity field in symfony.
It works well when i choose a regular entity field.
$builder
->add('parent','entity',array(
'class' => 'AppBundle:...
2
votes
1
answer
106
views
Using macros with dynamic name using dot operator does not work
While upgrading twig v1.30 to v3.22.0 i encountered some problem using macros from an external file and calling them by using a variable value as dynamic name.
Given the twig file with the macros:
{# ...
Advice
0
votes
3
replies
78
views
Symfony monolog add additional info to all logs
I need to add trackability information for all logs.
E.g. logged in user and route parameters (entity ID)
Right now I have this code:
use Monolog\Processor\ProcessorInterface;
class RequestProcessor ...
-1
votes
1
answer
67
views
How to require login for a custom controller?
we are implemented a custom controller for one webspace of our sulu 2.6 installation. It requires login against our SSO, but the problem is, that the result is cached.
We have 4 Webspaces, just one ...
1
vote
1
answer
617
views
Saving Datetime Immutable object as Datetime in database with Symfony and Doctrine without default comment
I'm building the Symfony entities from the existing database dump, and decided to switch from Datetime objects to Datatime Immutable, which don't have to change anything in database. But in the ...
1
vote
2
answers
148
views
Avoid Doctrine to return full related entity
I am new in Symfony and I am trying to get all the records from my content table. It works but it also returns all the fields from the related entity.
$content = $this->contentRepository->...
6
votes
2
answers
9k
views
"Connection refused" while trying to connect to docker mysql container [closed]
My question is how to configure connection to mysql container.
Here is my docker-compose.yml
version: '3'
services:
php:
build: ./php-fpm
volumes:
- ./iym:/var/www/iym
- ./...
2
votes
1
answer
57
views
Symfony/Doctrine: PostgreSQL Migration Issue – Undefined column error only in HTTP Kernel (CLI works)
Symfony/Doctrine: PostgreSQL Migration Issue – Undefined column error only in HTTP Kernel (CLI works)
I'm working on a Symfony 7.3 project running on PHP 8.2. I recently migrated the database from ...
3
votes
3
answers
4k
views
Symfony ux-react: React component does not render when using react_component()
I've initialized a new Symfony project with version 6.3.3 and wanted to try out the symfony-ux stuff with React. So I followed this guide: https://symfony.com/bundles/ux-react/current/index.html
But I ...
1
vote
2
answers
11k
views
How to create JWT token in Symfony5?
I'm trying to create REST API with JWT authentification in Symfony5. At first I've tried to do as written here https://h-benkachoud.medium.com/symfony-rest-api-without-fosrestbundle-using-jwt-...
0
votes
2
answers
56
views
Symfony UX LiveComponent with collection
I'm using a LiveComponent to access a form with a OneToMany collection.
Adding an item works perfectly, but when I delete an item, the entire collection is deleted.
The code is below.
->add('...
1
vote
3
answers
10k
views
Can't canonicalize query: BadValue $or/$and/$nor entries need to be full objects - Doctrine
I am trying to covert this query
db.getCollection('queues').find({
$and:[
{queue: 'testo'},
{$or: [
{$and: [{reserved_at: null}, {available_at:{'$lte':1490323024}}]},
...
1
vote
1
answer
2k
views
Is it possible to get the actual class name instead of the proxy class name from a lazy loaded object using Doctrine's MongoDB ODM?
Prior to beginning upgrade work to update my application to Symfony 3, and with it upgrading several libraries (including Doctrine) to more recent versions, I was able to compare references in a query ...
15
votes
6
answers
25k
views
How to exclude deprecation messages from logs in Symfony 4?
I have migrated an application from Symfony 3.4 to Symfony 4.4.
Now I have a lot of deprecations for each request/ Sf command (I can't fix that deprecations).
How can I exclude deprecations from the ...
0
votes
1
answer
529
views
Symfony2 use getDoctrine() in AppKernel to dynamically register bundles
I have created an application where I can manage multiple websites. There are a lot of "extensions" (bundles) that can be used in the websites if they have the right to use it. The rights (...
5
votes
1
answer
4k
views
Doctrine: Explicitly giving primary key value while not changing the auto increment
There is a table with many columns along with primary key column 'id' having auto increment attribute.
The database is mySQL.
There are two kinds of PHP code that are inserting in that column.
1.) ...
2
votes
3
answers
19k
views
How to add bootstrap datetimepicker in Symfony form
I'm trying to use http://eonasdan.github.io/bootstrap-datetimepicker/ in my Symfony form.
I added:
<link type="text/css" rel="stylesheet" href="{{ asset('assets/css/bootstrap-datetimepicker-...
1
vote
1
answer
79
views
RememberMe doesn't work correctly with basic FormLogin
Using Symfony 7.3, I have this basic security.yaml:
form_login:
login_path: app_login
check_path: app_login
enable_csrf: true
success_handler: ...
-1
votes
0
answers
37
views
Cannot import js package installed with importmap in symfony 6
i've installed swiper js with importmap:require swiper in symfony. it download a umd version of the package in the vendor/
Note: i use it in a stimulus controller
We cannot import Swiper from "...
4
votes
1
answer
1k
views
Api Platform use Post to get data using an input
I'm working with Api Platform, Symfony and Doctrine. I'm expecting a JSON of an object from my frontend, which is essential in procuring the data from my backend. Since GET requests don't/should not ...
0
votes
1
answer
63
views
POST search on API-Platform
I’m trying to create a getCollection route using POST with API Platform.
The idea is to perform a search that takes a JSON payload to handle search conditions first, and later manage relations, ...
0
votes
2
answers
5k
views
Environment variable not found: "DATABASE_URL" (Symfony 5)
I've just started using Symfony. Firstly, I have no database in my small project. However, it forces me to use DATABASE_URL. So, I have to create a database. When I do this, the project works. Do I ...
24
votes
6
answers
28k
views
lazy loading with doctrine one to one mapping
I am having a hard time finding the correct result for this.
I have one to one mapping. There are two tables:
/**
* @ORM\Table(name="users")
* @ORM\Entity
*/
class Users {
/**
* @ORM\...
2
votes
1
answer
9k
views
How to set variable as undefined?
I know it is easy to check if a variable is defined using
{# defined works with variable names #}
{% if foo is defined %}
...
{% endif %}
and to set a variable if it is undefined using:
{% set ...
0
votes
0
answers
76
views
Symfony UX Live Components - debounce filter on `data-model` with `data-action` attribute
I have a menu that is using Live Components that shows, loads more, and filters through a list of brands. It shows a list of brands with checkbox for each, that acts as a filtering option on the page. ...
2
votes
3
answers
17k
views
Set Symfony uploaded file by URL input
Via an XML import I'm getting also an url link to jpg images on an external server. I want to copy the images. I'm tried to do this via UploadedFile() function in Symfony to then add them in my entity....
-1
votes
2
answers
3k
views
Symfony mail catcher (mailpit) refuses connection from code, works from console [closed]
I am trying to set up a development environment with Symfony running in Docker. Recently I installed the symfony/mailer package with the option to install a mailcatcher, which turned out to be axllent/...
2
votes
1
answer
5k
views
What to return after $response->send() in Symfony2 controller?
If I prepare a response in my controller like so:
$response = new Response();
$response->setContent($this->render('mytemplate.html.twig');
$response->send();
Rather than using:
return $this-&...
3
votes
1
answer
7k
views
New Symfony UX Live Components work but aren't updated interactively
I've been asked by a client to look into Symfony UX's Live Components for use in an internal project. We/they are away of its alpha status and the fact that it will likely change and break over time ...
2
votes
1
answer
104
views
Show several markers on a map with Symfony UX Map
I would like to have multiple markers on the same map with Symfony and UX Map!
I've read the documentation but can't find the solution there!
At the moment, I can get all the markers but on different ...
2
votes
1
answer
128
views
How I can direct an event from a specific transport to a specific bus?
In my symfony project I have this configuration upon messenger.yaml:
framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
failed: 'doctrine://...
10
votes
2
answers
2k
views
Moving from nelmio/api-doc-bundle's PHP annotations to attributes with Rector
I am working on a Symfony REST API project and trying to update the framework and all my dependencies to the latest version. I recently moved to PHP 8.3 and am trying to embrace the new PHP attributes ...
0
votes
1
answer
217
views
Checking request requirements in PHP Symfony: Do I have to use services? (OOP vs Services in Symfony) [closed]
I'm working on my second Symfony project and trying to follow best practices. I've switched from static methods to services for improved readability and potential performance gains. For instance, I ...
0
votes
2
answers
682
views
Accessing Attributes of parent class
I'm using PHP8 attributes to flag Doctrine entities in a Symfony project, to set the entity up for audit logging.
To determine whether the entity should be audited I would check whether it has an #[...
0
votes
2
answers
2k
views
Symfony-twig template form theme error
I have everything working correctly and now I'm trying to work with form themes. This is my code to generate the form without a theme.
{% extends 'base.html.twig' %}
{% block body %}
{% include 'menu/...
2
votes
0
answers
45
views
Symfony 6 - EasyAdmin - Custom form type canvas
I use Symfony 6 with EasyAdmin,
I've been trying for several hours to understand how form types work in Symfony, and more specifically how to set up a custom form field, but I can't find a simple, ...
2
votes
1
answer
173
views
Why does doctrine/doctrine-bundle cause errors in my symfony / composer project after upgrade?
When trying to do a "composer upgrade", it fails in "@auto-scripts" when reaching doctrine/doctrine-bundle.
The error is:
Executing script cache:clear [KO]
[KO]
Script cache:clear ...
3
votes
2
answers
11k
views
How to increase PHP memory limit for Symfony project under Windows?
I have a Symfony3 project on my localhost (Windows 7 Entreprise) and I use Wamp Server 3.0.0 with PHP 5.6.16 and Apache 2.4.17.
When I do : php bin/console cache:clear
I have this error :
I also ...
5
votes
2
answers
3k
views
Hash user password without User instance in symfony
As it can be read in the official documentation, the current procedure to manually hash a password in the Symfony framework, is the following:
use Symfony\Component\Security\Core\Encoder\...
6
votes
1
answer
2k
views
Symfony Profiler: show response content?
Currently using the Postman REST client to debug my ajax calls, I would like to know if there a way to show the response content of an ajax response inside the Symfony profiler ?
I can only seem to ...
3
votes
1
answer
2k
views
Is there a built in list of http response codes and their DESCRIPTIONS in Laravel or Symfony? [duplicate]
Everyone on the internet seems to understand that http response codes have a certain 'description' or 'message'. For example, 404 has the description "Not Found".
So I would expect ...
1
vote
3
answers
4k
views
Can traits have services injected?
In my Symfony 4.4 project I want to add specific method every time I trigger setSomething() setter method, but perhaps I can use traits?
Can traits have services injected?
9
votes
5
answers
15k
views
Symfony "no PHP binaries detected"
Ive been just starting to learn Symfony PHP framework, and Ive run into some problems with its configuration.
When trying to create a new project with command line like so:
symfony new --full ...