spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » SYMFONY2 » Page 1
How do I Download the Symfony Distribution as Zip archive?
you should download the zip from the official Git-Repo at: https://github.com/symfony/symfony-standard The dl link is in the lower right corner.

Categories : Symfony2

Remove web part of url in web.config for Symfony 2
You should point your IIS root directory of website to your web directory (not symfony root directory). This will remove web from your url and (more important) this is adviced because of security reason - only web directory should be accessible EDIT: If you do not want to change your wwwroot then I would advice to use symbolic link in windows (mklink command) and create a link called symfony unde

Categories : Symfony2

You have to use the choice field type ->add('myField', 'choice', array( 'choices'=> array('choice1'=>'printedvalueofchoice1','choice2'=>'printedvalueofchoice2'), 'multiple'=> false, 'expanded'=> false )) expanded set to true will turn your select into radio options

Categories : Symfony2

OneToOne relation with sonata_type_admin : field not linked to an admin
Your mapping is not correct. There should not be such line. @ORMColumn(name="image", type="string", length=255) @ORMColumn overrides @ORMOneToOne and Doctrine sees this field as simple field - not as association. http://doctrine-orm.readthedocs.org/en/latest/reference/annotations-reference.html#annref-onetoone

Categories : Symfony2

how to define variable in yaml symfony2
The way of defining parameters it's correct, however I see from comments that your purpose is to configure the class used for User object: As Cerad said you can't do that. But if you want to configure the class you use for the User, you can have a manager service class. <?php namespace YourNamespaceUserBundleManager; use DoctrineCommonPersistenceObjectManager; class UserManager { /**

Categories : Symfony2

Symfony2 Lifecycle Events wont fire on update() function
Use the entity manager to trigger the lifecycle event rather than writing the update query yourself. // get the entity manager as $em ($em = ...) $cc = $em->getRepository('your:repository')->find($id); $cc->setPrivate($private); $em->flush(); Check out Doctrine Lifecycle Events

Categories : Symfony2

Error when trying to acces website url during deployment Sympfony2
You need to give write permissions for the two following folders : app/logs app/cache Have a look at symfony configuration and setup doc.

Categories : Symfony2

In Symfony 2 / Doctrine 2, can you change the inheritance at runtime (i.e. add a class)?
Take a look at this bundle, it might be exactly what you're looking for: https://packagist.org/packages/netpositive/discriminatormap-bundle Basically it allows you to leave the DiscriminatorMap annotation empty and fill it in your configuration.

Categories : Symfony2

Doctrine2 Many To Many Polymorphic Relations
You could solve this with OOP, using inheritance. Define an abstract class Taggable, and make Post and Video extend that class. Then create a OneToMany from Tag to Taggable. Doctrine will take care of everithing, supposed that you choose between Single Table Inheritance or Class Table Inheritance. I would choose Class Table, though. More on this subject here.

Categories : Symfony2

Force Doctrine to Load Associated Entities in JOIN
If you want to avoid Lazy Loading (recommended for loops), Doctrine suggest that you JOIN an entity at the time of the query. But you also have to add the entity to the SELECT statement, e.g. ->join('e.settings', 'settings') ->addSelect('settings') From the Doctrine Docs on Join A SELECT query can contain joins. There are 2 types of JOINs: “Regular” Joins and “Fetch” Joins.

Categories : Symfony2

How to implement two tables intersection on Doctrine2 Symfony2
First off the template is using a variable which hasn't been defined (entities): return $this->render( 'ACMEAppBundle:Default:index.html.twig', array( 'entities' => $clientsWithTotals ) ); Implementing the Repository: class ClientRepository extends EntityRepository { public function getClientsWithTotals() { $this ->createQueryBuilder('cl

Categories : Symfony2

How to run a command when a Symfony2 project is online (production mode)
You can use https://github.com/CoreSphere/ConsoleBundle If you have the "no route" error, try to access to yoursite/web/app_dev.php/_console/_console as the prefix defined in your routing_dev.yml will be added to the path defined in the Bundle's routing.yml routing_dev.yml _console: resource: "@CoreSphereConsoleBundle/Resources/config/routing.yml" prefix: /_console #routing.yml f

Categories : Symfony2

Best practices of naming the keys for Symfony transaltion component
You can check the best practices book SensioLabs deliver few weeks ago here : http://symfony.com/doc/current/best_practices/index.html There's a part about best practice for translations. Hope it'll helps !

Categories : Symfony2

Symfony 2 security issues with multiple providers, multiple firewalls and multiple hosts
Change public_secured_area firewall like this: public_secured_area: ... logout: path: /dashboard/logout target: /login anonymous: ~ or change app routing like this: public_logout: path: /public/logout host: app.example.dev Both route and logout path should be the same..

Categories : Symfony2

Testing Symfony2 emails with Behat 3
It's not the answer your are looking for, but I'm pretty sure it will suits your needs (perhaps more). If I can suggest, try using Mailcatcher with this bundle: https://packagist.org/packages/alexandresalome/mailcatcher You'll be able to easily tests if emails are sent, what's their subject, follow a link in the body, and so on... Many steps are included with this bundle.

Categories : Symfony2

I cannot see doctrine:generate:migration command in symfony2
Hi @user3475484 you should check DoctrineMigrationBundle. Ya you are right we cann't found this console command in standard Symfony2 package because it is not part of Symfony2 standard vendors. So you have to install doctrine migration bundle as suggest in this link.

Categories : Symfony2

How to get Sonata Media Bundle to generate pictures in separate folders
We worked out a "workaround" for this problem: Basically what we have done is that we created our own Generator, Provider and Resizer to match our needs and than injected it back to the Media Bundle. The generator implements Generator Interface, the constructor only has one argument ($this->firstLevel = 1000;). Than: public function generatePath(MediaInterface $media) { $rep_first_level = (i

Categories : Symfony2

Symfony2 and guzzle compatibility
Here is a working composer setup for Guzzle using Symfony 2.5.6: "symfony/symfony": "2.5.6", ... "guzzle/batch": "~3.7", "guzzle/service": "~3.7", "guzzle/plugin": "~3.7", "guzzle/log": "~3.7",

Categories : Symfony2

Symfony DI injects an empty array instead of entity manager object
This fails because Symfony is passing the options array expected by the parent Constraint class. You need to split your validator into two classes: one annotation class, and one that does the actual validation. /** @Annotation */ class UniqueBookingDate extends Constraint { public function validatedBy() { return 'unique_booking_date_validator'; } } Now set up a service call

Categories : Symfony2

No route found for "GET /numbers"
So you have prefix. In that case your route should be @Route("/{number}") http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#route-prefix

Categories : Symfony2

Symfony 2 application on Vagrant + Docker
I haven't used vagrant with docker, but I have had a simliar issue just using vagrant and symfony. I had to configure the permissions for the logs and cache dirs in the vagrant file, so something like this (guest is Ubuntu 14.04): config.vm.synced_folder "symfony/app/cache", "/vagrant/symfony/app/cache", owner: "www-data", group: "vagrant", mount_options: ["dmode=775,fmode=664"] config.vm.synced

Categories : Symfony2

Symfony2 authenticate user through an API on integration testing
session.storage.mock_file uses by default %kernel.cache_dir%/sessions for a storing of session's file. Check if this folder is writable for both server user and cli user. 'Setting up Permissions' http://symfony.com/doc/current/book/installation.html#configuration-and-setup Another 2 possible reasons of error: stateless: true on your firewall in firewalls section. The ContextListener is not cr

Categories : Symfony2

Running two Symfony commands at the same time
Could you try using something like a Makefile both: make command-one make command-two command-one: app/console foo command-two: app/console bar Then to run you could do make both or make command-one or make command-two

Categories : Symfony2

How to set form name in Symfony2?
Could you add the attribute to your twig template. {# src/Acme/TaskBundle/Resources/views/Default/new.html.twig #} <form action="{{ path('task_new') }}" name="myCustomFormName" method="post" {{ form_enctype(form) }}> {{ form_widget(form) }} <input type="submit" /> </form>

Categories : Symfony2

Symfony2, get value of input field with Twig
try this . {{ path('client_view',{"id": form.name_field_hidden.vars.value}) }} Have more information on http://symfony.com/doc/current/reference/forms/twig_reference.html

Categories : Symfony2

How to display Events in Calendar page
First you have to parse your events as fullCalendar event object, following event documentation var myEvent = {id: 1, title: 'myTitle', start: moment(...)} Then, you should add those events to an array, function, json... var mySourceEvents = [myEvent, myOtherEvent]; Finally you could set that array in your fullcalendar config as a source. $('#calendar').fullCalendar({ eventSources: [

Categories : Symfony2

Symfony2 + tinyMCE Bundle - JustBoil.me don't show
you need to copy your justboil.me plugin to tinymce plugins folder. rename justboil folder to jbimages here is example how to include plugin and configure button in toolbar plugins : "preview,jbimages", toolbar: "jbimages | bold italic underline | fontsizeselect", hope this helps you

Categories : Symfony2

Doctrine ORM Custom Column Collation
This has been added by now if you (or someone else) still need, see http://doctrine-orm.readthedocs.org/en/latest/reference/annotations-reference.html#annref-column Example: /** * @var string * * @ORMColumn(type="string", length=64, nullable=false, options={"collation":"utf8_bin"}) */ private $code; This is supported by all common database drivers now.

Categories : Symfony2

Invalid field override named 'email'
EDIT: You're right, there is mapping info in FOSUserBundle/Resources/config/doctrine/model/User.orm.xml... <mapped-superclass name="FOSUserBundleModelUser"> ... <field name="usernameCanonical" column="username_canonical" type="string" length="255" unique="true" /> <field name="email" column="email" type="string" length="255" /> Just guessing: Maybe this xml orm co

Categories : Symfony2

Symfony2 ConsoleExceptionListener ConsoleExceptionEvent get Arguments and Options
I found the answer I was looking in the wrong place $command = $event->getCommand(); As described in the question Command has no methods to get it but ConsoleExceptionEvent $event has a method to get the input (Arguments and Options) $event->getInput();

Categories : Symfony2

Get entity assert property in form view (or in form builder) to use with JS
Why don't you do it like the Validation in the cookbook ? Is far more easier than to do it inside your Entities. And at the same time you have the benefit of not having your entities coupled to Symfony. # src/Acme/BlogBundle/Resources/config/validation.yml AcmeBlogBundleEntityMyEntity: properties: myfield: - Count: min: 1 max: 3

Categories : Symfony2

Twig Loader prependPath not working
According to the docs, When you render the template you need to reference it with the namespace you aliased to that path e.g. @MyWebsiteFront/Index/index.html.twig When using the setPaths(), addPath(), and prependPath() methods, specify the namespace as the second argument (when not specified, these methods act on the "main" namespace): $loader->addPath($templateDir, 'admin'); Namesp

Categories : Symfony2

Increase label index in symfony2 form from the controller
Finaly I got the solution: First I created a new type under MyBundle/Form/Type wish extend the sonata_type_collection I created this class: namespace AAAAABundleFormType; use SymfonyComponentFormAbstractType; use SymfonyComponentFormFormBuilder; class CustomSonataTypeCollectionType extends AbstractType { public function getParent() { return 'sonata_type_collection'; }

Categories : Symfony2

twig testing global value in template
Exactly, as Oligan said: {% if {{role}} == 'front2' %} Is wrong. You need to use: {% if role == 'front2' %} Only use {{variable}} outside conditions.

Categories : Symfony2

Symfony 2 try to get wrong route in prod environment
Okay the problem was that my kernel cache pointed to a wrong location so .. i overrided it : public function getCacheDir() { return $this->rootDir.'/my_cache/'.$this->environment; } Thanks for the help all

Categories : Symfony2

how to set max_size in OneupUploaderBundle?
I will suggest an alternative way, since doing it like this didn't worked for me too. Do it with event listeners: // Resources/services.yml yourbundle.oneuploadvalidatorlistener: class: AmineyourBundleEventListeneroneupValidator arguments: [%your_own_defined_maxBytes%] tags: - { name: kernel.event_listener, event: oneup_uploader.validation, method: onValidate } Note that if y

Categories : Symfony2

Query Builder or Closure or DQL, which is the right one for get ride of this complex SQL query with ManyToMany relationship?
When you create a ManyToMany relationship in your entity, Doctrine will generate the third table as mediator between those two entities (named in @ORMJoinTable) with two fields (defined in joinColumns). You do not have direct access to the fields or columns in the third table but they all will be handled by Doctrine in your DQL. This means in your DQL you need to just set the joint table id in you

Categories : Symfony2


Recently Add
Exception handling app/logs/dev.log
How do I Download the Symfony Distribution as Zip archive?
Remove web part of url in web.config for Symfony 2
OneToOne relation with sonata_type_admin : field not linked to an admin
how to define variable in yaml symfony2
Symfony2 Lifecycle Events wont fire on update() function
Error when trying to acces website url during deployment Sympfony2
In Symfony 2 / Doctrine 2, can you change the inheritance at runtime (i.e. add a class)?
Doctrine2 Many To Many Polymorphic Relations
Force Doctrine to Load Associated Entities in JOIN
How to implement two tables intersection on Doctrine2 Symfony2
How to run a command when a Symfony2 project is online (production mode)
Best practices of naming the keys for Symfony transaltion component
Symfony 2 security issues with multiple providers, multiple firewalls and multiple hosts
Testing Symfony2 emails with Behat 3
I cannot see doctrine:generate:migration command in symfony2
How to get Sonata Media Bundle to generate pictures in separate folders
Symfony2 and guzzle compatibility
Symfony DI injects an empty array instead of entity manager object
No route found for "GET /numbers"
Symfony 2 application on Vagrant + Docker
Symfony2 authenticate user through an API on integration testing
Running two Symfony commands at the same time
How to set form name in Symfony2?
Symfony2, get value of input field with Twig
How to display Events in Calendar page
Symfony2 + tinyMCE Bundle - JustBoil.me don't show
Doctrine ORM Custom Column Collation
Invalid field override named 'email'
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.