Symfont 2.3 + FOSRestBundle - symfony

I am trying to follow the tutorial ## but am running into an issue.
I am receiving the following exception:
Call to undefined method Symfony\Component\Config\Definition\Builder\NodeBuilder::fixXmlConfig() in DIR\vendor\jms\serializer-bundle\JMS\SerializerBundle\DependencyInjection\Configuration.php line 46
Does anyone know what is going on?
I have enabled both required bundles:
new JMS\SerializerBundle\JMSSerializerBundle($this),
new FOS\RestBundle\FOSRestBundle(),
I'm guessing that one of the bundles is not updated to 2.3 as of yet maybe?

If you use the dev-master branch for both dependencies you can get it up and running.
composer.json
"require": {
...
"friendsofsymfony/rest-bundle": "0.12.0",
"jms/serializer-bundle": "dev-master",
"jms/di-extra-bundle": "dev-master"
},
AppKernel.php
new JMS\SerializerBundle\JMSSerializerBundle($this),
new FOS\RestBundle\FOSRestBundle(),
This seems to have sorted it for me.

Related

How to do logging in my app using symfony's Depenency Injection module?

I've read the current docs on Symfony integration with Monolog, but all it says is to run:
composer require logger which throws an error "package not found". (https://symfony.com/doc/current/logging.html#installation)
I'm using these components:
"require": {
"symfony/dependency-injection": "~3.0",
"symfony/yaml": "~3.0",
"symfony/config": "~3.0",
"symfony/console": "~3.0",
"symfony/validator": "~3.0",
"symfony/event-dispatcher": "~3.0",
"guzzlehttp/guzzle": "~6.0",
"gedex/janrain-api": "~0.1"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"friendsofphp/php-cs-fixer": "~2.0",
"squizlabs/php_codesniffer": "~3.0",
"symfony/var-dumper": "~3.0"
},
I want to do logging using dependency injection and config module.
EDIT: it is not a web application. It is a library that provides abstraction and exposes internal API, and I want to make it possible to log what is going on in the methods.
Looking at your composer.json, you seem to be on Symfony 3.x still. The docs for your version are at https://symfony.com/doc/3.4/logging.html.
The composer require logger is a shortcut which works with Flex. Flex is default on Symfony 4, but optional for Symfony 3. If you’ve upgraded from an earlier version, I assume that you currently don’t use Flex. In this case, you can install monolog and its Symfony integration by running:
composer require "symfony/monolog-bundle": "^3.1.0"
Then you must add the monolog bundle to your AppKernel:
$bundles = [
…
new Symfony\Bundle\MonologBundle\MonologBundle(),
…
];
Then you can inject the #logger service into your own services or call it in your controllers.

TYPO3 Composer dependency conflict

I'll be brief:
I have a TYPO3 with composer installed.
Let us have a look at the require part from TYPO3.
"require": {
"php": ">=5.5.0",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-session": "*",
"ext-xml": "*",
"psr/log": "1.0.*#dev",
"pear/http_request2": "~2.2.1",
"swiftmailer/swiftmailer": "~5.4.1",
"symfony/console": "~2.7.0",
"symfony/finder": "~2.7.0",
"doctrine/instantiator": "~1.0.4",
"typo3/class-alias-loader": "^1.0",
"typo3/cms-composer-installers": "^1.2.8",
"psr/http-message": "~1.0",
"cogpowered/finediff": "~0.3.1",
"mso/idna-convert": "^0.9.1"
}
As you can see TYPO3 needs "symfony/console": "~2.7.0" so that means: (>=2.7 <= 2.8)
Next to it I run a CakePHP with the migrations plugin for the custom CakePHP Part.
Let's have a look at the require part from the database migration plugin as well:
"require": {
"php": ">=5.4",
"robmorgan/phinx": "0.5.3",
"cakephp/cakephp": "~3.1"
},
Nothing wrong here on the first look, but let us go in detail and have a closer look at "robmorgan/phinx": "0.5.3". This Plugin needs the following packages, and again let's have a closer look at the composer.json from "phinx".
"require": {
"php": ">=5.4",
"symfony/console": "~2.8|~3.0",
"symfony/config": "~2.8|~3.0",
"symfony/yaml": "~2.8|~3.0"
}
And now as you can see this package needs "symfony/console" at least in 2.8, but it doesn't work because TYPO3 needs it in "~2.7.0" that means: (>=2.7 <= 2.8).
I figured out the issue, but I have no idea how to solve it. I only have one solution but it is not that great, it's forking TYPO3 and editing the composer.json. But that is the very last option.
Does anyone else have a good approach on how to fix this?
You can use version 8.x of TYPO3. This version uses as requirement "symfony/console": ">=2.7 <3.1",which looks absolutly fine then.
8.x is very stable, you can use doctrine all over the place and it is the future.

Sonata Admin / Media conflict (CRUDController)

I have a conflict / problem between sonate admin and media bundle.
Here is the error :
Runtime Notice: Declaration of Sonata\MediaBundle\Controller\MediaAdminController::render() should be compatible with Sonata\AdminBundle\Controller\CRUDController::render($view, array $parameters = Array, Symfony\Component\HttpFoundation\Response $response = NULL, Symfony\Component\HttpFoundation\Request $request = NULL)
The error happen while in the backend I try to interact with the media control panel (automaticaly added by the media bundle).
The only mention of this error on google is talking about dependencies issues.
https://github.com/sonata-project/SonataMediaBundle/issues/731
Here is the composer.json
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "^2.3",
"sonata-project/media-bundle": "^2.3"
If to change for "sonata-project/media-bundle": "dev-master" it's also not working
The service "sonata.media.admin.media" has a dependency on a non-existent service "sonata.classification.manager.category".
and anyway I'm not sure I want to use 'dev' packages.
Is this Sonata project still working ? the doc is outdated
I'm extremly tired of these sonata bundles - seems like a good idea but it's so time consuming to configure them properly ...
So here is the trick :
in your composer.json you need to use the following version :
"sonata-project/admin-bundle": "^2.3",
"sonata-project/doctrine-orm-admin-bundle": "^2.3"
"require-dev": {
"sensio/generator-bundle": "~2.3", <== CHANGE THIS !!!
},
in the require-dev you need to change "sensio/generator-bundle": "3.0" to "sensio/generator-bundle": "~2.3"
This doesn't solve the original issue, but will make sonata admin / media working together.
thx to chalasr for helping.

Symfony 2.1.7 and doctrine migrations bundle error

I am following this tutorial: http://tutorial.symblog.co.uk/docs/extending-the-model-blog-comments.html#doctrine-2-migrations
1) Installing Doctrine migrations bundle
1.1) - adding
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master"
to composer.json
1.2) running
php composer.phar update
2) adding
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
in AppKernel.php
3) Running
php app/console doctrine:migrations:diff
this should run the command and find the differences between the current entities and the database, yes?
But I get an error instead:
Fatal error: Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found in D:\xampp\htdocs\symblog.dev\app\AppKernel.php on line 23
This is exactly the line of (2.)
Can you help me out? Any advice is welcome!
I think the bundle was renamed in the meanwhile. Try: (updated question):
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
//...
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
);
}
See DoctrineMigrationsBundle documentation and DoctrineMigrationsBundle class.

mopabootstrap bundle and symfony2 issue

I am using this mopabootstrap bundle, followed all of the instructions. I am getting the following error:
An exception has been thrown during the compilation of a template ("Unable to find file "#MopaBootstrapBundle/Resources/bootstrap/js/bootstrap-transition.js".") in "MopaBootstrapBundle::base.html.twig".
I found the thread here that seems to have an answer to my issue as well, but i tried it and it still gives me the same error. How can I fix this?
If you are using the latest version of MopaBootstrap, and Symfony 2.1 or 2.2, it seems that the twitter/bootstrap files aren't correctly installed and symlinked.
Maybe you have missed the composer.json part:
{
"scripts": {
"post-install-cmd": [
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
],
"post-update-cmd": [
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
]
}
}
from the MopaBootstrap doc
Those commands create the symlink from the vendors folder: /vendor/twitter/bootstrap
to the MopaBootstrap folder:
/vendor/mopa/bootstrap-bundle/Mopa/BootstrapBundle/Resources/bootstrap
Be sure to also install twitter/bootstrap in your composer.json:
{
"require": {
"mopa/bootstrap-bundle": "dev-master",
"twitter/bootstrap": "dev-master"
}
}

Resources