ConfigCache::__toString() is deprecated since version 2.7 - php

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.

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).

Retrieving an array of classes in a directory

I'm using Symfony's ClassMapGenerator to get an array of all classes inside a directory:
ClassMapGenerator::createMap(__DIR__ . '/Generators')
This works just fine - but the ClassMapGenerator class was deprecated in Symfony 3.3, and completely removed in symfony 4.
Since we've just performed an upgrade to Symfony 4, this code no longer works.
I've read this article that explains why it was removed, but doesn't offer any alternatives.
Any ideas?
I figured out how to solve this by replacing the Symfony import with Composer's ClassMapGenerator.
use Composer\Autoload\ClassMapGenerator;
The syntax is exactly the same

Symfony4 migration: The "doctrine.database_create_command" service is private

I'm starting to migrate my application to symfony4 but I have the following deprecation notice in one of my third-party bundle ( tbbcmoneybundle . And I would like to know what to change in order to propose a PR
Currently the build is failing because of these errors (complete report here )
The "doctrine.database_create_command" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead: 25x
12x in ConfigTest::setUp from Tbbc\MoneyBundle\Tests\Config
6x in ConsoleTest::setUp from Tbbc\MoneyBundle\Tests\Console
3x in ConsoleTest::testRunRatioList from Tbbc\MoneyBundle\Tests\Console
2x in ConsoleTest::testRunRatioFetch from Tbbc\MoneyBundle\Tests\Console
1x in ConfigTest::testHistoryOfFetchedRatio from Tbbc\MoneyBundle\Tests\Config
1x in ConsoleTest::testRunSaveRatio from Tbbc\MoneyBundle\Tests\Console
I guess it's related to this code
$this->runCommand($this->client,'doctrine:database:create');
$this->runCommand($this->client,'doctrine:schema:update --force');
However I don't see see how to fix this and google seems unhelpful on this one.
The problem looks like it comes from the loss of container awareness (if that's a valid phrase) in Symfony 4, which started in Symfony 3.4. This blog talks about restricting container injection in 3.4 and how it will go away in 4.0.
It looks as though someone has opened a PR to upgrade to Symfony 4, but that is failing. (Looks like you're trying to help that along as well.)
According to this Travis integration test that is failing, the commands which extend "ContainerAwareCommand" are the source of the fail.
Which makes sense. The ContainerAwareCommand attempts to inject the Container, which is set to private in Symfony 4 (and deprecated since 3.4) as outlined in the blog post above. A fix, and I think you want to fix this in a PR to TBBC if I read your question correctly, seems to be to remove the extension of ContainerAwareCommand from those command classes and just inject the services necessary. See the new Symfony 4 doc on commands (and note that ContainerAware is no longer an option as it was in 2.8-ish.)
In short, get rid of the extension to ContainerAwareCommand and inject the services used by those commands. (Might need to do some extra configuration to ensure that the services are public.)

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.

FOSUserBundle : configuration error (handler)

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.

Categories