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.

"Encountering issues while trying to establish a connection to localhost with Behat and Selenium

Setting up my Behat tests in a Selenium environment has been quite a challenge for me. Currently, I have managed to start Selenium with Docker. This is what my docker-compose.yml configuration looks like: hub: image: selenium/hub ports: - "4444:4 ...

Utilizing Symfony REST DTO validation and injecting it into the Model similar to a paramconverter

Is there a way to create a request filter for post actions in a JSON REST API that takes the request's body, fills the DTO, validates it, and injects it into the controller action like paramconverter? I have an ExampleDTO structured like this: class ...

Enhance the Many to Many connection

Currently, I am involved in a Symfony 3 and Doctrine project where I am dealing with a many-to-many relationship between Pack and Produit: Pack Entity: class Pack { /** * @var ArrayCollection | Produit[] * @ORMManyToMany(targetEntity="App ...

Retrieving an entity by its ID from various entities in Symfony2

Imagine we have a collection of entities: $entities = $em->getRepository('MyBundle:Entity')->findBy(array('cat' => 1)); What is the most efficient way to retrieve a single entity from this collection by its ID? While iteratin ...

Running FeatureContext with bin/behat @FootballTeamBundle is acceptable, but bin/phing is not suitable for this task

When I execute bin/behat @FootballTeamBundle in the terminal as a standalone command, the error screenshots are captured and stored under the build/behat/ directory, which works fine. However, when I run bin/phing, the entire FeatureContext file appears to ...

Unable to locate any services for fixtures to load

This question has been asked multiple times before: Symfony 3.4 and Fixtures Bundle issue with bundle version 3.0 Symfony 3.4.0 Could not find any fixture services to load Symfony Doctrine can't find fixtures to load Could not find any fixture servi ...

Having trouble getting your Symfony2 application to work with Behat and Selenium2 for mobile testing?

Struggling to configure Behat tests for mobile devices in a Symfony2 project. I currently have the Selenium standalone server with Chromedriver running. Below is my behat.yml configuration file: default: suites: default: contexts: - ...

Setting the application version for the Symfony WebProfiler is a simple process that can easily be

After reviewing this specific commit, it appears that there is now an option to set a custom application name and version for the WebProfiler. This raises the question of what the recommended method for doing so is? /** * Constructor. * * @param string ...

NoMethodFoundException encountered in applicationDevelopmentDebugProjectContainer.php at line 1606

I'm feeling a bit lost with the issue I'm facing here. Everything was working fine with my app, but then something changed and now I'm encountering this error. I even tried clearing my dev cache, but no luck. I suspect it might have been due ...

Modify the CSS when CKEditor is in focus

Implementing CKEditor in a symfony project using the FOS\CKEditor-bundle 1.2. I want to style the entire element containing CKEditor with a border when it is focused, similar to how questions are written or answered on Stackoverflow. By referencing a ...

You're in need of a "cli-config.php" or "config/cli-config.php" file within your project in order to operate the Doctrine ORM with Silex via the command line

I've been attempting to integrate Doctrine ORM with Silex, but I'm encountering a frustrating challenge due to the inconsistent documentation provided. Upon running vendor/bin/doctrine in the console, the following message is displayed: output: ...

Troubleshooting Doctrine's setParameter function and handling invalid parameter numbers

After numerous attempts, I believe I have finally mastered the documentation. However, I am puzzled by an error that Doctrine keeps showing me: Invalid parameter number: the count of bound variables does not match the count of tokens Below is the code ...

How can I use Symfony and AJAX to upload files that are included in JavaScript JSON objects?

My client is uploading files embedded in JSON objects which include metadata for each file. The challenge I am facing is not knowing the exact number of files they will upload, so I need a dynamic solution. Currently, I have a javascript object called fi ...

Using Symfony to override a set function in an Entity with the id of a different Entity

Is it possible to modify a set function of an entity based on a field from another entity? I have a field in table 1 (column E) that could contain either the value from column C or D (although having two fields with the same information seems messy, I am ...

Send a JavaScript variable to Twig

I am trying to pass a JavaScript variable to a twig path but the current method I am using is not working as expected. <p id="result"></p> <script> var text = ""; var i; for (varJS = 0; varJS < 5; varJS++) { text += "<a href= ...

What are your thoughts on creating a dedicated bundle for services in Symfony as a best programming practice?

I'm currently working on a symfony app that offers REST based services. One of the modules I have is called UserBundle, which handles user login, logout, and registration actions. In addition to the UserBundle, I have other bundles that provide resources ...

Invalid Credentials - ajax authentication - Symfony2 / AngularJS / FosUserBundle

I have successfully implemented FosUserBundle with the regular web/app_dev.php/login login. The AuthenticationHandler is set up as shown here. When my Angular application sends a JSON request, it includes the following data: _csrf_token: "uSRZfxMycFCLKbx ...

Guide on deploying a Symfony application automatically using GitLab CI on a private server

After discovering gitlab-ci to automate my development tasks, I successfully set up a "test" stage for running unit tests. Everything was working perfectly until I hit a roadblock: I wanted to automatically deploy to my dedicated server upon MR approval. ...

What is the best way to send a JSON response from a Symfony2 controller?

I am utilizing jQuery to modify my form, which is created using Symfony. The form is displayed within a jQuery dialog and then submitted. Data is successfully stored in the database. However, I am unsure if I need to send some JSON back to jQuery. I am ...

Is it possible to verify credentials across multiple sources such as a database, Active Directory, and

While I have been using my own authentication and authorization code with Symfony2 as a framework, I recently decided to explore Symfony's security system. Following the tutorial on their website, I successfully set up login using my database. However, no ...

What is the best way to submit a form using Vue Axios in combination with Symfony 4

Need help! I am struggling with sending data from my Vue app to Symfony using axios. Even though I try to send the data, the Symfony request doesn't seem to receive it. Check out my controller code below: $form = $this->createForm(TeacherType::class); ...

Issue with JMS Serializer SerializedName() Functionality Not Resolving

In the entity Foo, I have a special property called $character property. This property is actually another entity (AppBundleEntityCharacter). When serializing Foo, I only want to include the nickname of the Character entity, not the entire thing. To a ...

Changing the label of a ChoiceType in Symfony2

Within a form, I have a select field (choiceType) that automatically populates with all the lines from another table. I am trying to modify just the label of the select field without changing its content... For textType fields, I was able to achieve this ...

"Optimizing Long Polling for Maximum Efficiency: Tips for utilizing php, Jquery

Hey everyone, I'm looking to implement real-time flash message notifications for users when they receive a new private message in their inbox. What is the most effective way to achieve this using technologies like PHP 5.3, jQuery, and JSON? I prefer using ...

Explore the API documentation using Swagger

I am currently working on a project using Symfony4 with api-platform. The login process is defined in security.yaml as follows: security: encoders: AppEntityUser: bcrypt providers: our_db_provider: entity: class: AppEntityU ...

Exploring Symfony2: Enhancing user experience with dynamic form submission and dropdown menu updates

Starting from the beginning. I have a tab-panned layout with links. Upon clicking a link, a drop-down checkbox form is injected directly into the HTML through $(".dropdown-toggle").click(function() { var projectId = $("#permission-form").attr("data-p ...

Symfony 5 - PhpUnit Panther: ChromeDriver's current compatibility is limited to Chrome version 80

Currently, I am attempting to integrate Panther with PhpUnit in my project. However, I am encountering an issue when trying to log a user in the following manner: $client = static::createPantherClient(); /** @var User $user */ $use ...

selenium and behat: Provider not found for session

I'm currently working on setting up selenium in a docker container to use with Behat. However, when I check the status of the hub at http://localhost:4444/status, it shows that it is not ready: { "value": { "ready": false, &qu ...

Combining data from two tables with a join query, followed by displaying the results in

1) cms 2) cms_translations cms id url status cms_translations object_id title lang_id I have also created a cmsRepository file for handling this. $q = $em->createQuery("SELECT c , d FROM Dashboard\CmsBundle\Entity\Cms c JO ...

A comprehensive guide to implementing custom headers across all methods of a Symfony 4 Controller using FOSRestBundle

I'm developing an API using the FOSRest Bundle for creating a RESTful service. Currently, I am returning data along with custom headers by implementing the following code: class InvestorController extends AbstractFOSRestController { /** * This m ...

Is there a way to determine if a button was clicked using twig?

I need assistance with implementing a button in my twig file within a table that will remove an element from an array. Ideally, I would like to remove the element based on its index. From the research I have conducted, it seems that data manipulation shou ...

Starting point of a Symfony 2 project, redirecting visitors' journey

After setting up a Symfony 2 project, I decided to access it through a virtual host using the URL my_project.dev. However, when I visit this URL, it displays the index of my project instead of directing me to the desired home page. I am struggling to find ...

Tips on altering the method to invoke for an entity during the PreSerializeEvent

My application includes a Category entity that holds various Assets. The Category has a method called getCount which returns the number of assets it contains. Recently, there was a feature update that introduced new types of assets such as external and in ...

Guide to navigating back to the previous page after logging in with Symfony

I am implementing a controller to download files only for registered users. For example: www.myapp.com/download/123.jpg If a registered user tries to access this link without being logged in, the system redirects them to the login page. After logging ...

Maintaining an active link in a navigation list: A guide for Twitter Bootstrap

How can I make a link appear active when clicked, and keep it active while the user is on that page? (Using Symfony2 with Twitter bootstrap) <ul class="nav nav-list"> <li class="active"> <a href="/link1">Link</a> </li> &l ...

Issue with custom annotations in Symfony 4: @ORMEntity not recognized

While working on the development of my CMS, I encountered a specific issue that I need assistance with. The error message I am facing is as follows: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class ScyLabs\G ...

What is the proper way to format lengthy lines in Twig templates while adhering to coding standards?

In my templates, I have the following code snippet for generating routes with parameters: <a class="btn btn-block btn-abcd" href="{{ path( 'auth.login', { 'type': constant('User::TYPE_CANDIDATE'), 'provider': constant('UserProvi ...

Issue with Symfony 4: @ParamConverter annotation unable to locate object in Profiler exclusively

The issue is specific to the debug toolbar. Highlighted below is the code section I suspect might be causing the problem /** * @Route("/{category_slug}/{slug}", name="content_show") * @ParamConverter("content", options={"mapping": {"slug": "slug"}} ...

Symfony FOSRestBundle API encounters a JSON Request body that is missing data

I'm having an issue while building a Symfony API with the bundle. Every request I send results in an empty body response. Here is the code snippet of the Controller: class IndexController extends AbstractFOSRestController { /** * @Rest\ ...

Having trouble executing encore dev

Why do I keep encountering errors when trying to use "yarn run encore dev"? Whenever I attempt to add Sass, I receive a warning stating that "[email protected]" has an unmet peer dependency of "webpack@^2.0.0 || ^3.0.0 || ^4.0.0". But why is this happ ...

Symfony 3.4 is not compatible with installing dotenv via composer

I am currently working on a Symfony 3.4 project and I'm encountering some issues while trying to install the Dotenv component. After running the command composer require symfony/dotenv:^3.4, Composer indicates that there is "Nothing to install update. ...

Issue with disabling cache in Symfony using the config.yml file is not resolving

As a beginner with Symfony, I am currently working on a project that involves making UI changes. However, I am facing an issue where the changes I make are not reflected on the screen until I manually delete the cache files located in app/cache. While this ...