The server globals (like $_GET) are populated by Apache. When running the functional test, Apache is skipped so $_GET is not populated anymore. Instead of using the server globals, you should use the Request object to extract the GET parameters. This way, the framework will intercept both the PHPUnit injected...

When you try to clear cache but its not getting cleared you should use --no-warmup option, this will make sure that you cache is re-generated and cache is not warmed up only. I think this can help you: php app/console cache:clear --env=prod --no-warmup or php app/console cache:clear --env=dev --no-warmup ...

You can simplify your code to, i guess your session array would look something like array( '11' =>array('id'=>'11','title'=>'some product','product_quantity'=>2), '12' =>array('id'=>'12','title'=>'some product','product_quantity'=>1), '13' =>array('id'=>'13','title'=>'some product','product_quantity'=>3), ); key in your cart array will be product id so there will be no chance of duplicate product in array now in below code...

If you check the logger interface (https://github.com/php-fig/log/blob/master/Psr/Log/LoggerInterface.php) you will see all of the logging methods gets message as a string, thus you get a warning when you try to log with a variable type other than string. I tried to use a processor to format the array in a custom...

The easiest way is to define an translations file. # app/Resources/translations/validators.es.yml This value should not be blank.: Campo obligatorio This value is not a valid email address.: e-mail no válido ...

You have not included the Symfony EnityRepository class at the top of your form file so PHP is looking for it in the same directory as your form class. Hence the error message. Add this to your form class (or qualify EntityRepository inline): use Doctrine\ORM\EntityRepository; ...

When you store doctrine entities in the session they become detached from the EntityManager. You need to merge any entities which are already in the database back into the EntityManager. Something like this (checking for null where necessary): foreach($contactPersons as $key => $contactPerson) { $mergedCountry = $em->merge($contactPerson->getAddress()->getCountry()); $contactPerson->getAddress()->setCountry($mergedCountry); $em->persist($contactPerson); }...

You are reading article about Console Component. This is slightly different than registering a command in your bundle. First, your class should live in Namespace Command, and it must include the Command prefix in classname. You've mostly done that. I will show you a sample command to grasp the idea...

You can try that way, monolog: channels: ["testchannel"] handlers: test: # log all messages (since debug is the lowest level) level: debug type: stream path: "%kernel.logs_dir%/testchannel.log" channels: ["testchannel"] And in the controller you can get the logger and do your thing; class DefaultController extends Controller { public function indexAction() {...

The Symfony validator service can be used directly to validate any object for which validation constraints are defined. For example in a controller: $validator = $this->get('validator'); $errors = $validator->validate($test); To perform validation within a service you can pass the validator service into your service....

In your composer.json you have these lines: "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web", You need to update those and run composer update to make your bootstrap.php.cache file ready for the new structure....

You can use Crawler::filterXPath() to check for the presence or even absence of html elements matching all sorts of criteria. To check for the presence of a link I prefer to use the element id as that is most likely to remain constant. For example, if you modify your link...

You could add a hidden field to you query that sorting things in the order that you wanted so that you don't need to process the complete ArrayCollection to sort. public function findByArticleInOrderOfState() { return $this->createQueryBuilder('c') ->select('c') ->addSelect(' CASE WHEN c.state = :state_new THEN 1 WHEN c.state = :state_viewed THEN...

One way would be to override the template that is used when editing. Now, what you need to do is: Create new directory (if you already haven't) in app/Resources called SonataAdminBundle. Inside, create another one called views. This would create a path like app/Resources/SonataAdminBundle/views. This is Symfony basic template overriding....

There's no change you can make to your annotations to make this work with your existing relationships. You have defined a nullable one-to-one relationship between the Contact and User entities. From a class perspective this means that a Contact's $user must either point to an instance of User or be...

I’m not sure if you ask for server-side validation or assistance for client-side uppercase input. In case of the latter: you could add a CSS class or a data-* attribute (something like ->add('PID', 'text', ['label'=>'License Number', 'required' => FALSE, 'attr' => ['data-behavior' => 'uppercase']])) to the PID element. Then, you...

It depends on your intention. If you want to directly push part or all of the XML to an entity/document object for saving to a database then the JMSSerializerBundle can do this very smartly and is definitely the best way to do it. If however you just want to extract...

When you omit the name it's being autogenerated for you. The autogenerated name is a lowercase concatenation of bundle + controller + action. For example, if you have: Bundle AppBundle Controller MyController Action: testAction() the name would be app_my_test. You can list all routes using Terminal: php app/console router:debug All...

You could use a doctrine entity listener: https://symfony.com/doc/current/bundles/DoctrineBundle/entity-listeners.html http://doctrine-orm.readthedocs.org/en/latest/reference/events.html#entity-listeners And have something like this in it: public function postUpdateHandler(Vote $vote, LifecycleEventArgs $event) { if (null === $vote->getValue()) { // Following two lines could be avoided with a onDelete: "SET NULL" in Picture orm mapping $picture = $vote->getPicture(); $picture->removeVote($vote); $this->em->remove($vote);...

The solution for openSuSE: Install xvfb-run (on other *nix-systems maybe "xvfb") Change in the config part of the bundle (in app/config/config.yml) the binary option from "wkhtmltopdf" to xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf Check the folder permissions. For german users: http://www.antondachauer.de/2015/06/19/wkhtmltopdf-unter-opensuse-mit-symfony-knpsnappybundle/...

In the Symfony documentation How to Create a custom UserProvider, under 'Create a Service for the User Provider' it states: The real implementation of the user provider will probably have some dependencies or configuration options or other services. Add these as arguments in the service definition. So, rather than using...

From the Symfony docs and this section as well: Notice that in the original example that included JavaScript files, you referred to the files using a path like @AppBundle/Resources/public/file.js, but that in this example, you referred to the CSS files using their actual, publicly-accessible path: bundles/app/css. You can use either,...

If user's email is similar in both social accounts, you can use email field to identify user. You should create user provider class. If user with provided social token won't be found in database, user provider will try to find user by email and add new social token for specified...

It's normal that the creation of a new email is not associated to a skin object. How could it ? The relation is unidirectional, and only works when you create a skin and you give it an email. To create an email and give it a skin, you have to...

Found a working solution : Add a function in my global controller which check if session is still active and responds with "ok" if yes, "ko" if not. public function pingAction() { $securityContext = $this->container->get('security.context'); if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) { return new Response("ok"); } return new Response("ko"); } and i...

When you create two entities with a one-to-one relationship, both entities need to be persisted either explicitly or by using cascade persist on one side of the relationship. You also need to explicitly set both sides of the relationship. Doctrine - Working with Associations - Transitive persistence / Cascade Operations...

I havent tried this bundle yet, but i think you need to tell doctrine that you want to save your newly created feed into the database: $feeds = new Feed; $reader->readFeed($url, $feeds, $date); $em = $this->getDoctrine()->getManager(); $em->persist($feeds); $em->flush(); return $this->render('default/index.html.twig'); UPDATE According to the docs if you want to use...

This may be a little hacky, but manually wiriting the token to the session achieved what I wanted $token = new UsernamePasswordToken($user, null, 'account', $user->getRoles()); $this->get('session')->set('_security_account',serialize($token)); // Needed to prepend "_security_" to the firewall name to get "_security_account" Didnt even need to call lines such as //Didnt seem to need...

You can use angular.service Services Angular services are substitutable objects that are wired together using dependency injection (DI). You can use services to organize and share code across your app. click here for More details ...

I think you have to override the class for test.client which, by default, uses Symfony\Bundle\FrameworkBundle\Client. Something like: <parameters> <parameter name="test.client.class">My\Bundle\AppBundle\Test\Client</parameter> </parameters> First, take a look at the base class Symfony\Component\BrowserKit\Client. If you look at the request method of this class you will find this: public function request(/* ... */) {...

An Entity field is the wrong thing to use in this case - the form will try to map an instance of the Technical class onto the Services's integer $techId field, which cannot work. You need to use a standard choice field and pass the list of (Technical entity) id...

Even if your service lies in the same namespace as it's your template, that does not mean that you can call it directly like that. Did you tried the way you render normal controller templates, like this: ->setBody($this->twig->render( 'AppBundle:Emails:email-voucher.html.twig', [ 'order' => $order, 'voucher' => $voucher, 'customer' => $customer ]...