Questions tagged [symfony]

18841 questions
1

votes
2

answer
1.3k

Views

Can't set form value on a functional test

I'm currently doing this tutorial: http://tutorial.symblog.co.uk/docs/testing-unit-and-functional-phpunit.html I'm at the "Test contact page" part. There we have defined a test called testContact() http://pastebin.com/PtzwY7PJ (edited by me, the outcommented stuff results in the same error) If I run...
xotix
1

votes
2

answer
2.3k

Views

Is this a good idea to use Yii Framework with Doctrine 2 ORM?

I love Yii Framework, it works fast, it's pretty cool and easy to develop with. But now I have a problem - I am going to develop Learning Managment System with difficult domain logic and it's not good for me to use Active Record from Yii for my models, it would be better to separate mapping and doma...
Andrei Nestser
1

votes
1

answer
3.1k

Views

Run phpunit tests on symfony2 core and bundles

I created a new symfony 2.4 project and would like to run the test suite on core and bundles just to know phpunit is installed properly and to see the outputs, but can't figure out what am I doing wrong I installed phpunit via composer Now there is a link to phpunit bin/phpunit I try bin/phpunit -c...
jeff
1

votes
3

answer
4.3k

Views

How to download a file from view in Symfony

I have a app made with Symfony2 and in my twig template, I show a table with some pdf files. This pdf files (one for user) are stored in /app/var/pdf/xxx.pdf. If I use: PDF My path is correct, for example: symfony/app/var/pdf/123123.pdf, but when I click in the link, my browser return a 404 Not Fou...
user2794692
1

votes
2

answer
321

Views

How can I pass a error 500 message to my error template?

Using Syfmony2, I have created custom error templates, in my case it is /app/Resources/TwigBundle/views/Exception/error.html.twig and looks somehow like this ERROR {{ status_code }} {{ status_text }} When I now throw an error with a message in it: throw new Exception('There is something wrong in the...
Gottlieb Notschnabel
1

votes
3

answer
122

Views

Symfony2 - Need help on the following error when querying for tags

Having the following error in my doctrine query when trying to find a specific tag selected by the user. [Semantical Error] line 0, col 78 near 'tag WHERE blog.tags': Error: Class Acme\DemoBundle\Entity\Blog has no association named tags Can someone tell what's wrong with the query? (trying to query...
esteemed.squire
1

votes
1

answer
847

Views

Jquery File uploader in Twig file not working

I am using this code for jquery file uploader i found(plugin) in this some lib files is given which i have included but still getting error in my twig file. Lib file is : tmpl.min.js Error-: unclosed for and Unexpected character ";" at line 1 Line 1: {% for (var i=0,file; file=o.files[i]; i++)...
Sunil Rawat
1

votes
1

answer
456

Views

How to pass entity atribute value to form Symfony2?

I have a form type: $builder->add('paises', 'collection', array( 'options' => array('data_class' =>'Acc\ApssBundle\Entity\Pais'), 'prototype' => true, 'type' => new PaisType(), )) ; How to add attribute "name" to the class Pais to the label form ?? In twig I have: {% for pais in form.paises %} {{...
Alex
1

votes
1

answer
959

Views

Create my own entity generator on symfony using doctrine generator

I am building an entity generator in order to update my DB's structure and data according to a distant one (DB), via SOAP WS... I get the structure from an array, and am currently writing my entity classes by myself, with a file_put_content(). But as I advance, I can't help noticing that the Doctrin...
Cedo
1

votes
1

answer
103

Views

Symfony2 - How can I limit the number of records an user can store?

I'm building a SaaS project using Symfony2, Doctrine2 and Postgresql. I have three different subscription plans, and for each plan there is a limit of members each user can store. How can I limit a user to not store more members that the allowed for his subscription plan? Should I use a pre-persist...
marc casas
1

votes
1

answer
1.1k

Views

Switch roles FOSUserBundle

I am using FOSUserBundle for handling my users. For them I have 2 roles ROLE_CUSTOMER and ROLE_MANUFACTURER. The problem is that I need to be able switch these roles when I am logged in. Is it possible? I have read this documentation: http://symfony.com/doc/current/cookbook/security/impersonating_u...
RydelHouse
1

votes
1

answer
2.2k

Views

Get admin and object id in a twig template (sonata admin)

How do i get the id of the admin and object in a twig template using sonata admin? I have tried admin.getId() and object.getId() but that didn't work. Any ideas?
Rafael Bermúdez
1

votes
1

answer
688

Views

How to structure account balance system

This is more of a theoretical question on how to structure a user accounting balance architecture. For the stack we are probably going to use Symfony with Doctrine, but I don't think that the language is most relevant. The problem: We need to create and maintain a usage balance for each user for ou...
John
1

votes
2

answer
729

Views

How to add comment for table in yaml mapping format with Doctrine2

I need to add comment for whole table, not only for column, How can I do it with yml mapping format. I try next definition: Acme\DemoBundle\Entity\User: type: entity table: users comment: 'Users table' options: comment: 'Users table' But it not work for table comment.
Victor Bocharsky
1

votes
1

answer
1.6k

Views

Symfony 2.3 Gedmo doctrine extensions translatable caching

I'm using Gedmo Doctrine extensions All works well so far, except for translations caching. $entity = $repository ->findByIdFullData($id) ->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker') ->useResultCache(true, $cache_time, $cach...
CRONUS
1

votes
2

answer
2.1k

Views

Twig Eclipse plug-in syntax highlighting

I need to develop with Eclipse a lot of twig view files, to be used with Symfony 2. I'd like use syntax highlighting and code assist. Then I installed the Twig Editor Feature 1.0.13 plugin by Dubture on my Eclipse. It seems installed correctly , I see the new Twig Editor and it's associated to .twig...
Eric Draven
1

votes
1

answer
465

Views

symfony First call take too much time

why Symfony takes too much time on first call, then OK, then after some mins too much time again. Permanent MYSQL connection (improve speed, but not the solution) Symfony file cache not generated/modified after a long request, so it seems not to be the source of the problem. Logs / Debug etc, seems...
Mahmoud
1

votes
1

answer
1.4k

Views

Session should logout after 10 min in symfony2

I tried so far, Path CoreBundle / DependencyInjection / configuration.php namespace Funstaff\CoreBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; class Configuration implements ConfigurationInterf...
Chiku
0

votes
0

answer
6

Views

How can I output a value by key from array with twig?

This is my array category: array:4 [▼ 0 => Category {#7535 ▼ -id: 1 -name: "Frog" -color: "#62bbd1" …2 } 1 => Category {#7551 ▼ -id: 2 -name: "Monkey" -color: "#e9a5a9" } 2 => Category {#7381 ▶} 3 => Category {#7540 ▶} ] I want to get the color of the Category with the id 2. So the outpu...
marila
0

votes
0

answer
4

Views

Dynamically switching database with Doctrine on Symfony

I am trying to connect to a different database from the one defined in my configuration. I based most of my code on this answer on SO and it seems that things have changed since Symfony 2. I am using Symfony 3.4 with Doctrine ^2.6 In my DatabaseChangeService.php : public function changeDatabase(\Doc...
gogaz
1

votes
1

answer
2.2k

Views

Symfony 2.6 “PropertyAccessor” exception: Expected argument of type “object or array”, “NULL” given

Symfony is giving me an error on a CRUD page in my admin back-end: Symfony 2.6 exception: Expected argument of type "object or array", "NULL" given Full stack trace is below, line 132 of the pertinent source file is here: https://github.com/symfony/PropertyAccess/blob/master/PropertyAccessor.php Has...
Kzqai
1

votes
1

answer
1.1k

Views

Integrating Whatsapp API in symfony

I am trying to integrate the WHAnonymous API in my symfony project. I have included it in my project using composer install and it is now in my vendor folder. But I am not understanding how to import it into my project! This is my manager class. I have used require_once 'whatsprot.class.php'; and r...
user3425344
-1

votes
0

answer
20

Views

php - importing contacts from csv file

I need to import contacts from csv file. If the contact exists in the database I update it. But I met a strange behavior. Suppose I have 5 contacts in csv, and the last one is already in database. When findOneByUserIdAndPhone works it returns empty record. If I uncomment "//continue", on last circle...
user3351236
1

votes
2

answer
905

Views

Symfony - Event not being dispatched

This is the first time ever I am working with creating custom event dispatcher and subscriber so I am trying to wrap my head around it and I cant seem to find out why my custom event is not being dispatched. I am following the documentation and in my case I need to dispatch an event as soon as someo...
Saadia
1

votes
1

answer
2k

Views

Doctrine query WHERE IN - many to many

I am building out a hotel website in Symfony2. Each hotel can provide many board basis options such as Self Catering, All-Inclusive etc. On my search form the users can filter by all of the usual fields such as location, price, star rating and board basis. Board basis is a multiple select check box....
Scriptable
1

votes
1

answer
154

Views

Symfony forms, labels not to be translated

I have some labels in a form which don't need to be translated (for example, IBAN, PayPal Email, Skype...) Can i avoid translating them (it would increase the translation files size uselessly), without having the "Missing messages" error? I'm using a standard Doctrine Entity + FormType class + Twig...
the_nuts
0

votes
0

answer
4

Views

Symfony4 - Validate fields based on values of other fields

I am building a very large form with multisteps and some conditional fields and cannot find a good solution for my problem. For example if field A is "Foo" then field B is shown via Javascript and must be validated via Symfony, otherwise the field must be empty. Is there a Way to do this? PS: Is ht...
André Rinas
1

votes
2

answer
519

Views

How to ask user to provide input in custom Console Command?

So I made command with two arguments: class ServerCommand extends ContainerAwareCommand { protected function configure() { $this ->setName('chat:server') ->setDescription('Start the Chat server') ->addArgument('host', InputArgument::REQUIRED, 'Provide a hostname') ->addArgument('port', InputArgument...
user6827096
1

votes
1

answer
182

Views

Twig function for repeating template

I'm new to Twig and recently started a project. In this I use a Star Rating Display very often, which needs also some values, e.g the rating to display or the size. Currently, I always use {% include 'Artist:rating.html.twig' with {'rating': artist.rating, 'size': 'medium' } %} everywhere, which...
pguetschow
1

votes
2

answer
90

Views

How to combine andWhere and orWhere with Doctrines Criteria

I want to create a rather complex and flexible query with Doctrines Criteria. I have an andWhere that is included in every query, but then (depending on input) I want to add some optinal parameters with orWhere. $criteria = Criteria::create(); /* Add Criteria for last 55 Days (every query) */ $crite...
PrimuS
1

votes
0

answer
5

Views

symfony/var-dumper in html format with live or hot reloading

I use symfony/var-dumper with the html format, I am wondering if there is a way to watch this html file online, so as not to reload the page (live / hot reloading). Is there a ready-made solution in a Symfony? Do you think it makes sense to debug in this way?
0

votes
0

answer
12

Views

HttpFoundation Session stand alone component and forms renderer

(I deleted previous similar subject, because there was too many changed in the code). I use Symfony\Component\HttpFoundation\Session\Session and Symfony\Component\HttpFoundation\Request but without all framework. I have simple index $request = Request::createFromGlobals(); $session = new Session();...
jaroApp
0

votes
0

answer
4

Views

How can I use leftJoin and DISTINCT on my query

I'm trying rewrite my SQL query to Doctrine, but I have big problem with DISTINCT option. SELECT DISTINCT airports_list.id, group_travel_airports.airport_id FROM airports_list LEFT JOIN group_travel_airports ON group_travel_airports.airport_id = airports_list.id AND group_travel_package_id = 109 WH...
Maciej Figlarz
0

votes
0

answer
5

Views

Calling guessExtension() on an uploaded .csv file returns .txt

My Symfony project consists of a file upload functionality. Upon uploading my demo.csv file, calling the guessExtension() method returns a value of .txt instead of .csv. Why is this the case and how can I correct this? $fileExtension = $file->guessExtension(); // returns 'txt' instead of 'csv' I kno...
Helenesh
0

votes
0

answer
9

Views

Using a FormMapper as a sonata.block.service

I'm trying to put a FormMapper used in an admin class on my Dashboard, so I fixed 2 blocks on my dashboard: dashboard: blocks: - position: right type: sonata.admin.block.admin_list - position: left type: ??? How can I call my FormMapper from an Entity here?
Ugo Lfe
0

votes
1

answer
28

Views

Can't send mail with Gmail

I'm trying to send an email when a user is subscribing in my web site. To save me time ... I'm using Swift_Mailer with Symfony. First, I tried to send a mail with the console : php .\bin\console swiftmailer:email:send And that's working, the mail was sent and the client received it. So now I said to...
WebIsOur
0

votes
0

answer
4

Views

Which Parameters How To Send Entity

I handle very many entity files . I want to form a system by analyzing the parameters which post over the API service .For this i am using a procedure as below. However, I am unable to analyze which service will operate in the last step. I'd be very happy if you can help. At this step, I have to sen...
Uğur ŞENSOY
0

votes
0

answer
6

Views

PDO driver missing on mac

I am trying to connect to mssql database from my Symfony 2.6 project. My project and system informations are as following macOS Sierra 10.12.6 Symfony 2.6 php 5.6.37 Few years ago I was able to achieve it by following run "brew install freetds" and "brew install php56-pdo-dblib" on terminal. By fo...
Abdul Ghaffar
1

votes
4

answer
10.7k

Views

curl (7): Failed to connect to localhost port 8000: Connection refused

Hello I am testing the endpoint and when I run php testing.php I get this error. Any help would be appreciated it. Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 7: Failed to connect to localhost port 8000: Connection refused [url] http://localhost...
Ris
1

votes
1

answer
2.4k

Views

View additional questions