Questions tagged [symfony]

The term "Symfony" encompasses a dual meaning: it signifies both a web application PHP framework and a collection of underlying components that form the foundation of this framework. For inquiries related to currently supported major versions (4.x, 5.x, 6.x, and 7.x) of Symfony, you may employ this tag. Alternatively, if you wish to address a specific version, kindly include the corresponding tag. It is important to note though that this particular tag should not be utilized for queries regarding Symfony 1.x. In such cases, please make use of the Symfony1 tag instead.

Troubleshooting Symfony2 and Assetic: Why are my CSS-linked images not loading?

I've encountered an issue with my CSS sprite sheet that my CSS file seems unable to locate the image. Despite following the provided solution here, I'm still facing the same problem. The directory structure of my bundle is as follows: src/ v ...

Why does PHP external API access fail when requested from a different page on the same domain?

Currently, I am experimenting with cross-site scripting using Jquery and PHP/Symfony (HttpFoundation Component), but I'm facing difficulties in obtaining the necessary data from the server. My objective is to have Jquery fetch JSON from the local dom ...

What is the best way to handle a Symfony 3 service that relies on a variable number of other services?

My experience lies in PHP, but I am fairly new to Symfony. Let's say I have a service that requires an unknown quantity of another service. It is not practical to inject it as I don't know how many instances would be needed. I could potentially use the Con ...

Why is TinyMCE removing my custom MPDF HTML elements?

I have a Vue application with a Symfony backend. I am using TinyMCE to edit documents that are generated by mpdf. In the mpdf twig content, I need to add a page footer on certain pages and exclude it on others. To achieve this, I have created custom HTML t ...

Implementing Ajax image upload functionality in Symfony2 framework

I am trying to implement a functionality where clicking on an image opens a window to select a new image and update the screen. However, when attempting to change the picture in the database, I encountered the following error: Catchable Fatal Error: Arg ...

Cross-origin request blocked on DELETE operation due to preflight failure

I've been grappling with this error for a while now. I'm currently developing an Angular app (version 1.6.1) and encountering issues when trying to call a delete method on the API, which is built in symfony 3. Initially, I faced a preflight error while us ...

Verify if a user is currently authenticated on the Silex PHP Framework

After being inactive for two hours, the system logs me out automatically. However, whenever I refresh the page, an error message appears stating that Silex cannot find the attribute displayName on a null attribute. The layout view contains: {{ app.user.dis ...

symfony submit form without sending request

I'm trying to make a request without using a submit button, only by selecting an option. So far, I've attempted to achieve this using JavaScript but haven't had any success. Here's my form code: $form = $this->createFormBuilder() ...

error encountered while establishing service namespace

New to working with Symfony2. I'm attempting to set up a service in my application by following the instructions in the Symfony documentation. Below is the code I have so far: File BC/MBundle/Resources/config/services.yml: --- services: metas: ...

Error: Unable to mount component - template or render function is undefined in Symfony Vue.js Encore application

I am currently working on integrating vue.js with Symfony. While this Vue.js configuration worked flawlessly in Laravel, I am facing difficulties with Symfony and unfortunately, I need to use Symfony for this particular project. My webpack.config.js is se ...

Inserting new element into Array collection on the api platform

One of the features in my Question entity is its 'OneToMany' relationship with Answer. My current query involves creating a unique endpoint with the path='question/{id}/add_answer', specifically designed for adding an answer to a specific question. How c ...

Retrieve the masterRequest URL within a fragment controller

Upon clicking a button, I have implemented a method that is triggered by an Ajax request. /** * @param Request $request * * @Route("/add", name="rapid_access_add", options={"expose"=true}) * @Method({"GET"}) * * @return Response */ public function ...

Instructions on merging the firstName and lastName fields to display them in the Full name column within Sonata admin

I am attempting to display a column for Full name that combines the firstName and lastName properties from my entity. How should I go about this? Below is the Entity and Admin.php code snippets: class test{ private firstName; //other properties privat ...

Using Icons in a Symfony ChoiceType Field

In my Symfony Form, I am attempting to display a SelectField with various icons. Here is what my ChoiceType looks like: ->add('icon', ChoiceType::class, [ 'choices' => [ '' => '', '' = ...

What benefits come from utilizing a Listener as a Service in place of a traditional Service?

Just starting out with Symfony here! Why would using a Listener as a Service be advantageous over just a Service? I've been checking out the documentation and I noticed that I can utilize a Listener as a Service: However, there's also the option of usin ...

What is the best way to display HTML code using Vue syntax that is retrieved from an Axios GET request

I am currently working on a project that involves a Symfony 5 and Vue 3 application. In this setup, a Symfony controller creates a form and provides its HTML through a JSON response. The code snippet below shows how the form HTML is returned as a string: i ...

Facing Memory Exhaustion Issue with Symfony 4 and Composer

Using Symfony 4... Executing the following command: php -d memory_limit=-1 composer.phar require form The process is successful up to this point... ./composer.json has been updated Loading composer repositories with package information Updating depend ...

What is the best way to combine these tables?

I currently have four tables - EdiTransaction, EdiTransactionDetail, EdiDocType, and Edi997Details. The EdiTransaction table has relationships with EdiDocType and EdiTransactionDetail, while Edi997Details is only related to the EdiTransaction table. I am w ...

Debugging a web application with Symfony2 and jQuery can be challenging, especially when encountering a 500 Internal Server Error

As I work on building an application using Symfony2 platform, I encounter an issue with a simple AJAX request that is triggered on document ready. jQuery.ajax({ url: 'test.php', type: 'POST', data: { 'test&apos ...

Increment Doctrine id after static insertion operation

After creating an SQL script with a large amount of data and running it in a postgresql Database, I encountered an issue while using the Doctrine2 ORM within the application to manage the database. The specific problem I am facing is as follows: When in ...

Adjusting the default format_date for SonataSonata's default

After successfully setting up the SonataIntlBundle bundle, I noticed that the default format_date displays dates as day-number month-name year. {{ date_time_object | format_date }} => '1 août 2011'Source Now, I am looking to personalize this default ...

Guide on integrating the $_SERVER variable into a Service

In one of the services within my application, there is a need to access a specific $_SERVER variable provided by apache known as $_SERVER['GEOIP_COUNTRY_CODE']; What options are available to fulfill this requirement effectively? At the moment, ...

The Symfony parameter for security, known as "json_login", fails to initialize the controller

I followed the tutorial on Symfony's documentation titled "How to Create an Authentication Endpoint using JSON in Symfony". However, I encountered a problem when making an AJAX call at my login handler. Instead of successfully logging in, I received a 500 ...

What is the process for passing arguments in Symfony?

Below is the routing information for the post route: cacic_uorg_type_excluir: pattern: /uorg/type/excluir/{idUorgType} defaults: { _controller: CacicCommonBundle:UorgType:excluir, idUorgType: null} requirements: idUorgType: \d+ This represents ...

What steps do I need to take in order to modify information within a table using Symfony?

Working on my Symfony project, I frequently need to display various views in table format. I wish I could easily update the data by clicking on table cells, entering new information, and saving it dynamically. After exploring jqGrid, DataTable with jEdit ...

How can you beautifully showcase the values in a text field with a Symfony 4 collection type transformer?

Currently I am working on a project using Symfony 4, and I have set up a ManyToMany relationship with a junction table. This setup allows entity A to have multiple instances of entity B, and vice versa. In this scenario, entity A is the owner of entity B. ...

Modifying the DateTime in doctrine proves to be a challenge

Seeking assistance on how to update the DateTime using Doctrine in my controller. The main objective of this page is to enable users to upload photos to a database, with only one upload allowed per user. Although everything else is functioning properly, ...

Symfony2 - Utilizing an Entity repository to encode data into JSON for efficient AJAX calls

I'm currently working on implementing a dynamic text field with AJAX autocomplete functionality. In order to handle the AJAX call, I have created a method in the controller. public function cityAction(Request $request) { $repository = $this-> ...

Prevent Symfony2 Twig from rendering HTML content

Is there a way to disable the rendering of HTML responses in Twig? I am currently working on a RESTful API and my goal is to completely prevent HTML rendering. For instance, if I access /foo/bar without an oAuth Access Token, Symfony2 should reply with a ...

Passing Controller Parameters to Symfony2 FormType

Working with Symfony2, I have a requirement to pass a parameter from the Controller to the FormType. Here is my Action snippet: public function addAction(Request $request) { $employee = $this->getUser(); if (null === $employee) { ...

Save a record and establish a connection with another record without saving the second record again

Currently, I am in the process of developing a front-end application using Durandal/Knockoutjs along with a web service backend created with Symfony2 that utilizes Doctrine for database access. In my project, I have two entities that are related in a one- ...

Relationship mapping for a singular inheritance entity using a one-to-many association

I am encountering an issue with the single table inheritance mapping for Doctrine ORM, also known as STI. It appears that having a one-to-many association from the STI entity to another entity is not possible. I have two entities named Customer and Suppl ...

Utilize several conditions in Doctrine Query Language for enhanced querying capabilities

In my database, there is a column named "refused" which can have values of 0, 1, or NULL. I am trying to retrieve rows that only have values of 0 and NULL. My attempt so far has been using the following code: ->andWhere('b.refused IS NULL') While th ...

What is the process for adding a counter variable to a field within a Twig file?

I'm working on a Twig file where I need to create a table and populate it with data using a loop. The issue is that all my field names are the same, so I want to add a counter variable to differentiate them. How can I achieve this? Below is the code ...

Updating or removing fullCalendar events in Symfony

I'm struggling to figure out how to update or delete fullcalendar events in my Symfony project. When adding a new event, I open a modal window with a form for submitting the event and inserting it into the database. This is my working controller: $ ...

Symfony2 does not receive any feedback from the Ajax request

Perform an ajax POST request with no response: Here is the ajax request code snippet: $.ajax({ method: 'POST', url: "{{ path('app-like-add') }}", data: { imageId: id }, success: function(response) { if (respons ...

"Effortlessly integrate Symfony3 with Select2 to create a dynamic tags

I am in the process of setting up a form to register food products in my database. Along with each product, I also want to include a list of ingredients found on the product packaging. For these two entities, I have created the following classes: Ingredi ...

Creating interactive forms with Symfony2 using embedded forms and event listeners

I created a form called "AddressType" with an event listener that functions correctly when used independently. Below is the code: namespace NcClientsBundleForm; use SymfonyComponentFormAbstractType; use SymfonyComponentFormFormBuilder; use NcCli ...

Implementing Autocomplete Functionality with Symfony3 Using AJAX and Chosen2

Hello there and thank you for assisting me. English is not my mother language, so please bear with me. :) Whenever I choose an item from the selectbox, I am greeted with a "no results found" message. However, upon inspecting the developer toolbar, I notic ...

Symfony3 controller constructor injection fails to work as intended

I am trying to inject the EntityManager instance into the constructor of my controller. Here is the code I have: namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Doctrine\ORM\ ...

FormBuilder Interface Silex File Input

Having recently subscribed, I have come to seek assistance on a platform where I have previously found many solutions to my issues. I have completed a course on Openclassrooms (Transitioning to a Professional PHP Architecture) which has equipped me with t ...

Is it possible to end a Symfony2 response in a function that is not the original requested action?

In the process of developing a RESTful API, I am utilizing Symfony2 along with FOSRestBundle and an OAuth 2 server library to enhance functionality. When handling requests, it is important to consider the various responses and status codes that can be sen ...

Symfony2 ParamConverter does not have a connection with @Annotation, so the cache needs to be cleared whenever a file is modified

My Controller relies on Annotations for Route, Method, Template and ParamConverter. However, I am encountering an error whenever I make any changes to the file, even if it's just a minor edit like a whitespace change or comment. Cannot import resourc ...

Need to store data with Symfony2 using OneToMany relationship?

I am faced with the following two entities : KTH : namespace NaukaOneBundleEntity; use DoctrineORMMapping as ORM; use DoctrineCommonCollectionsArrayCollection; /** * NaukaOneBundleEntityKth * * @ORMTable(name="kth") * @ORMEntity */ class K ...

Enhance Users Form in Sonata UserBundle to customize user experience

Hey there! I recently tried to follow the advice provided in this article: How do I go about removing fields from the admin user create page of Sonata User Bundle? I attempted adding/removing lines to the registration form of Sonata Userbundle, but encou ...

The progress bar for uploading in Docker with Nginx and PHP-fpm is not functioning correctly

Currently, I am employing docker-compose with PHP 7.2 from the phpdockerio/php72-fpm:latest image. services: webserver: image: nginx:alpine The configuration for nginx is as follows in nginx.conf: user nginx; pid /var/run/nginx.pid; ev ...

Dynamic service imports in Symfony 2 allow for the flexible inclusion of services

I have defined parameters as follows: parameters: config1: title: Title 1 data_proc: getDataOne options: [things, stuff] config2: title: Title 2 data_proc: getDataTwo options: [things, stuff] #... A ...

What is the best way to showcase the elements in my ArrayCollection while utilizing joined tables and ManyToMany relations?

Within my entity, I have a field named linkedDocuments: class Documents { /** * @ORM\ManyToMany(targetEntity="App\Entity\Documents") * @ORM\JoinTable(name="documents_documents", * joinColumns={@JoinColumn(name="link_origi ...

Symfony filesystem does not have read and write permissions for Phar archives

I've developed a CLI app that utilizes the Symfony 3 fileSystem component to create a file. Everything works perfectly, but when I package the app into a Phar archive, Symfony is unable to write the file. Here's how I created the Phar archive: ...

Behat Mink fails to locate file during upload submission

I'm currently testing image uploads using Selenium/Mink with Behat in a Symfony application running within a Docker container. Instead of using $driver->attachFileToField('#id-of-input', $filePath), I am attaching the file directly to th ...

What is the most efficient way to remove data from a database using queryBuilder?

Looking to remove specific data and retrieve the number of deletions made. Below is the code I am using: public function deleteMyData() : ?int { $qb = $this->connection->createQueryBuilder() ->delete('myTable') -> ...

Using JSON_ENCODE may attempt to evade double quotes

I have a controller that retrieves data from my database, formats it as valid JSON, but the HTTP response is text/html instead of application/json. This causes issues with getJSON not working properly. Should getJSON work regardless? public function send ...

Symfony: optimizing performance with kernel->loadClassCache and rendering multiple controllers

Hey there! I have a query regarding caching and rendering controllers. I've implemented $kernel->loadClassCache() in my app.php file to enable app caching. It's working fine as my site is now performing much faster :). However, I'm facing an issue wit ...

Changing a JSON reply to an object using JQuery within Symfony2

I recently delved into the world of AJAX and Json, working on creating a call for a thread of comments to be displayed on my webpage. After the controller finishes loading, it returns an array of objects in Json format: '[{"usr":"gigi","usrpic":"4993 ...

Elasticsearch FOS Integration: Error with ElasticsearchIllegalArgumentException

In my Symfony2 / Doctrine 2 application, I encounter an issue when attempting to run `fos:elastica:populate`: [ElasticaExceptionBulkResponseException] Error in one or more bulk request actions: index: /foodmeup/offer/4 caused MapperParsingExc ...

Symfony .htaccess - troubleshooting 500 error on third level domain

My application is located in a subdirectory at www.example.com/application/v1 and I have a third-level domain set up at v1.example.com. I am using Symfony2 and this is the content of my .htaccess: DirectoryIndex app.php <IfModule mod_negotiation.c> ...

The "Symfony QueryBuilder" is an outstanding tool

I'm creating a website that showcases various projects with a menu. This menu allows users to filter projects by language. However, I'm facing an issue with the query to retrieve projects for a specific language. I have two entities: Project and Language: ...

Leveraging the power of Symfony 5 for validating a recently created entity using the validation

Currently utilizing Symfony version 5.3.7 and incorporating the @Assert annotations for validating a new user during registration. Struggling to grasp the documentation and looking to comprehend how to apply these annotations for entity validation. Tried e ...

Customize the registration form within the Symfony FOSUserBundle

I have been working on modifying the default areas of the fosuserbundle registration form. I managed to add all the necessary fields I wanted by updating the database and customizing with the bootstrap cdn. However, I encountered an issue when attempting t ...

Using Symfony 3 to iterate through an array containing different Classes

Is there a way to extract values from JSON data that have been placed into my classes (Match, Player)? I attempted using a foreach loop, but found it challenging since the data is stored in classes. Can someone provide guidance on how to tackle this issue ...

Ensure that the Materialize CSS modal form remains open even after submission

Is there a way to reload a form inside a materialize modal with empty fields without closing the modal after submitting? The issue is that currently, when the submit button is clicked, the modal closes and redirects. <div class="modal" id="docM ...

Silex 2: Issue with security firewall and locale integration (Silex SecurityServiceProvider + PmaxsLocaleServiceProvider)

I came across this solution but unfortunately, I couldn't get it to work... Here is my code, along with what I've tried and the results I'm getting: My Code 1/ My Security Provider : $app->register(new Silex\Provider\Session ...

How can we set Symfony 2 to automatically preselect the drop-down field in the edit action?

In my database, I have 'category' and 'product' tables. Categories are displayed in a dropdown select box on the product form. When editing a product, I want the saved category in the product table to be automatically selected in the category dropdown on t ...

Using AJAX to submit a form with a file to Symfony results in $form->isValid returning false

Utilizing Angular JS code, I employ a method to submit a file and additional fields (along with a CSRF token) to a Symfony controller. var formObject = new FormData; formObject.append('email', self.careers[index].application.email); formObject.appe ...

I'm searching for the icon list within Shopware 6, where could it be located?

Is it possible to include an icon in a post using the sw_icon command? For instance: {% sw_icon 'head' %} Are there any alternatives to using 'head' for this command? ...

Symfony/AngularJS Blocked Cross-Origin Request

I am currently encountering an issue while attempting to retrieve data using Angular from my Symfony API, which returns JSON: "Cross-Origin Request Blocked: The Same Origin Policy prohibits reading the remote resource at http://localhost:8000/custom ...

Exploring Symfony2 controller integration with Javascript arguments

I am currently working on a project with Symfony2 and I have a question regarding receiving arguments from a template in a controller. My goal is to take the value of the argument and store it in the database. The argument's value will be generated by ...

Is it necessary to have a PHP accelerator installed for the Symfony 3.0 migration from PHP 5.5 to PHP 7.1? It is highly recommended to install and enable a PHP accelerator for optimal performance

In my SYMFONY 3.0 Project, I am looking to upgrade from PHP5.5 to PHP7.1. While exploring the "php.ini" file for the necessary changes, there is one unresolved issue: Previously, under PHP5.5, I utilized the extension accelerator php_apcu.dll. However, i ...

Conducting an AngularJS AJAX call within a Symfony2 environment and utilizing Doctrine to generate a JSON

Currently, I am working on a project involving Symfony2, Doctrine, and AngularJS. While Symfony2 and Doctrine are not causing any issues, I am facing difficulties when using an ajax request with AngularJS. The problem lies in either the data not loading pr ...

Api-platform in Symfony causing issues with event listener attachment

My issue lies with api-platform.com's event not attaching to my listener. Despite trying multiple combinations from their event matrix, the trigger still remains elusive. # services.yml user_access_listener: class: AppBundleEventListenerUserAc ...

error in assetic:watch - unserialize(): Offset error detected

While working on my project using everyday assetic in work (OS: Win7), I encountered an error today when I ran the command: php bin/console assetic:watch. The error message I received was: [SymfonyComponentDebugExceptionContextErrorException] Notice ...

Having HWIOauthBundle version 0.3.*@dev installed on Symfony 2.3.4 resulted in encountering the common error message "No oauth code present in the request."

I'm hoping I haven't overlooked anything important. Following the instructions provided in this link, I have successfully installed HWIOauthBundle (along with FOSUserBundle): https://gist.github.com/danvbe/4476697 I copied code from the files t ...

Challenges with Dependency Injection in Symfony 4.1 Components

Currently, I am in the process of updating an older PHP application. I am attempting to utilize Symfony's dependency injection component to inject services into controllers (and other services), but I am encountering difficulties as the Symfony docum ...

Comparing Symfony 3 features to their Symfony 4 counterparts

When transitioning from Symfony 3 to Symfony 4, what is the equivalent of the view directory? I am currently developing a simple todo list application in Symfony 4 and cannot locate the resources folder for creating views. ...

The controller in Symfony2 is unable to locate the registry service

I am working with a basic controller and need to utilize the entity manager: <?php namespace HanziGameMainBundleController; use SymfonyBundleFrameworkBundleControllerController; use HanziGameMainBundleEntityHanzi; class DefaultController ex ...