FOSUserBundle : configuration error (handler) - php

I'm using Symfony 2.1 for a project and trying to use FOSUserBundle to manage the users.I am also following the documentation but i'm getting an error:
Unrecognized options "handler" under "fos_user.change_password.form"
Any idea?
Thanks in advance!

FOSUserBundle recently went through several major changes in 2.0.x. The FOSUserBundle documentation as of right now is not up to date and currently is for 1.3.x and below.
If you would like to still use handlers, you can revert back to 1.3.x via composer. Take a look at the different releases on packagist.
The latest version of FOSUserBundle got rid of handlers and now uses EventListeners. You can take a look at the list of FOSUserEvents and decide which event you want to hook on to. You can see an example of subscribing to a FOSUserEvent from the controller on the "Hooking into the controllers" part of the documentation.
Also, note that if you're overriding the FOSUserBundle's controller, it now requires the Symfony2 Request component class as its parameter.

Related

Use Symfony entities and doctrine mapping without database

We are migrating our project from custom CMS to Symfony 5.1. Instead of Database, we are using REST API. Currently we are using Entities without connecting them to any database (with no #ORM annotation or configuration file), and we put all REST logic inside a Repository folder
Currently, if we save our entity in SESSION
$example = new Example();
$request->getSession()->set('example', $example);
On every next request, we will get error:
Class "App\Entity\Example" is not a valid entity or mapped super class.
Of course, this could be fixed if we put correct #ORM annotations, but then it requires a database.
Can this be fixed, and if it's not possible, what would be proper architecture for this scenario?
Let doctrine be the tool to manage the data. In fact that there is no database, you will need something similar to let doctrine manage the data of the REST API.
Take a look at this bundle:
https://github.com/CircleOfNice/DoctrineRestDriver
Edit:
In addition to one of the comments, the DoctrineRestDriver is not maintained anymore. In fact, the bundle does not support Symfony 5.x.
To use the functionality of DoctrineRestDriver you could downgrade your symfony to the supported 4.x.
Your architectur to use doctrine to manage your rest-api can be solved by using the DoctrineRestDriver package.
If you don’t want to downgrade your symfony, you will have to implement your own „data-manager-solution“, to use the api as your database.
But I think the architectural problem with the rest api doesn’t relate directly to your current error. We need more code to understand, where your specific mapped super class error is from (repository, entity).

ConfigCache::__toString() is deprecated since version 2.7

After updating to Symfony 2.7 I've got deprecated notification in my profiler. Here it is:
It looks like an internal Symfony stuff. Any ideas about how to fix it or it will be fixed in next Symfony patches?
It seems that the issue is located at the "AllowedMethodsRouterLoader" class. This might be an external bundle, so you might be able to update this bundle. If it's your own class, it's as easy as just changing it to using ->getPath() instead of using the ConfigCache instance as a string.

valid_children setting for Symfony Sonata / CMF

Continuing on the journey to install the Symfony2 CMF, I am getting the error:
[InvalidArgumentException]
The following document types provided in valid_children are invalid:
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page
The class names provided could not be loaded.
The following lines causing this error are here in the config.yml file:
sonata_doctrine_phpcr_admin:
document_tree:
/...
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page:
valid_children:
- all
/...
I am following the instructions from the docs here:
http://symfony.com/doc/current/cmf/cookbook/creating_cms_using_cmf_and_sonata.html
below Configuration. Is this an error in the docs, or a setting that need to adjust? The docs do not explain what the valid_children parameter is controlling or the possible settings.
What are the possible options for this setting? Any further explanation of what this code is actually doing would be beneficial.
Thanks for trying the CMF tutorials! This documentation was not tested recently (as the warning at the head of the page says). Thanks for pointing out this issue. I updated the tutorial and added some explanation:
The tree is used to know what is allowed in the left side of the admin dashboard, and also for sonata tree widgets. Classes in the tree where not validated at the time this tutorial was written, but are validated now to detect typos explicitly rather than having no clue why things do not show up in the tree. The simple cms is another bundle that can be used with the cmf, but which is not installed in the prerequisite tutorial...
http://symfony.com/doc/current/cmf/cookbook/creating_cms_using_cmf_and_sonata.html will be updated in the next few minutes.
Please open github issues on symfony-cmf-docs if you find further issues with this tutorial or elsehwere in the documentation.

Problems wit sign me up plugin

Hi i am trying to use Sign me up Plugin for my application. But unable to get it running. There are so many issues and errors.
Plugin i have downloaded is:-
sign_me_up-2.0
But there are so many errors i am getting
Ex:- Declaration of SignMeUpComponent::initialize() should be compatible with Component::initialize(Controller $controller)
I have tried for tutorials and serached for solutions online. But no luck...
Can anyone help me out on how to use this plugin ???
What i reffered :-
http://www.jotlab.com/2011/sign-me-up-a-cakephp-registration-plugin
Thanks in advance
Make sure your version of CakePHP is compatible with the plugin. I understand between version 1.3 and 2, they took advantage of the newer features of PHP which included strongly-typed method parameters. The error you're receiving is that the SignMeUpComponent inherits from the Component class which is in framework core. If the component wants to override the initialize method, it must follow the same method/function signature.
If the plugin is on Git and you feel comfortable in doing so, clone it and update all the components methods, and then put in a pull request so you're changes can be merged in.
Alternatively use an earlier version of CakePHP.

Symfony2 standalone form component - setting up a form

I'm trying to implement Symfony2 form builder component as a standalone. The documentation
doesn't really talk about this though, just in relation to using the whole framework.
The standalone is on Github but has no docs.
Ive searched around and seen a few people ask this question but none seems to have any answers.
All I need is a basic guide on how to setup a form , build it, then view it.
Anyone?
Edit: My first response below is now obsolete (and the link does not work anymore). Please refer to
https://github.com/webmozart/standalone-forms for a state-of-the-art solution.
Previous (now obsolete) answer:
I've tried hard and managed to display a form (using PHP engine, not Twig).
Indeed you need a few components: Form, but also ClassLoader, EventDispatcher, Templating (for rendering) and Translation (for rendering labels). You will also need some resources from the FrameworkBundle bundle (mainly templates).
More info on this:
http://forum.symfony-project.org/viewtopic.php?f=23&t=36412
And my mini-tutorial:
http://n.clavaud.free.fr/blog/index.php?article31/symfony2-standalone-form-component-tutorial
First, copy Form Component to your project to directory which contains third-party libraries (not only Symfony components, but also ORM or whatever), let's say lib/, so it's in <project_path>/lib/Symfony/Component/Forms.
Then you have to auoload it - either manually or using any PSR-0 compatible class loader i.e. SplClassLoader or Symfony's UniversalClassLoader (there is chapter in docs and in quick tour about this). Example:
$loader = new UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__.'/lib');
$loader->register();
Using Form Component isn't in fact strongly documented, but in Symfony Book there are few examples how to use Form classes about this component, so I guess you'll have to dive into sources, beginning with Form class (maybe later you'll give some feedback about experiences somewhere in the Web?).
Since Symfony 2.1, the form component has been using composer.
You can locate the composer.json file inside the repository. It contains a dependency map that can be used to get the dependencies installed.
You can do so by simply running composer install from inside your console.
P.S I know this thread is old. The information I'm contributing apply to any new users that may need it.
First of all not with Symfony2. But creating form with Aura.Input and some view helpers of Aura.View makes it easy to bring Standalone Forms and Validation.
If you are interested you can read it over http://harikt.com/phpform/ , and source is in github.
/*
* This file is part of the Symfony package.....
what i understand from that line is that the file is a PART of the framework, can't be removed, can't be ripped, and it won't function if you rip it off the package because it requires other related files in the framework
however, there is an option, and it is to investigate the files and see what functions they call and what variables they use ,redefine them, and use it as standalone IF the license allows you to

Categories