upgrade from symfony 2.0 to 2.3 - symfony

I already have running project which is in Symfony 2.0.10. But now I need to upgrade it to Symfony 2.3.I know there is need to change some code to compitable with latest version.Is there any command to upgrade? Or what is the exact procedure to upgrade? Is there any document available?.
Edit:
I put symfony 2.3 composer.json file and while doing php composer.phar update I got this error.
Problem 1
- symfony/symfony v2.3.1 requires symfony/icu >=1.0,<2.0 -> no matching package found.
- symfony/symfony v2.3.0 requires symfony/icu >=1.0,<2.0 -> no matching package found.
- Installation request for symfony/symfony 2.3.* -> satisfiable by symfony/symfony[v2.3.0, v2.3.1].
Edit 2:
First I got this error:
[InvalidArgumentException]
The dist file "app/config/parameters.yml.dist" does not exist. Check your dist-file config or create it.
so I created parameters.yml.dist file.
Now I'm getting
PHP Fatal error: Class 'Symfony\Component\ClassLoader\UniversalClassLoader' not found in /var/www/git/sample/app/autoload.php on line 6
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when generating the bootstrap file.

Upgrade information
Read the upgrade guides in symfony/symfony github repository:
Upgrade 2.1
Upgrade 2.2
Upgrade 2.3
Upgrade 2.4
Upgrade 2.5
Upgrade 2.6
Upgrade 2.7
Upgrade 3.0
There are also changelogs in the repository:
CHANGELOG-2.2
CHANGELOG-2.3
Backup your project!
Upgrading with composer
Get composer and put the symfony 2.3 standard edition's composer.json into your project root.
Now run composer update with your project's patch as working directory.
-> You will face some exceptions due to breaking changes exceptions. Google will help resolve those :)
Personal experience
In my legacy projects the most noticeable bc break from 2.0 to 2.1 was this one related to the form-builder because I had to update every form.
Before ( 2.0 )
use Symfony\Component\Form\FormBuilder;
public function buildForm(FormBuilder $builder, array $options)
After ( 2.1+ )
use Symfony\Component\Form\FormBuilderInterface;
public function buildForm(FormBuilderInterface $builder, array $options)

Upgrading is in general simple, as you only have to update the version constraints in your composer.json according to the standard distribution and issuing
php composer.phar update
But 2.3 has some backwards compatibility breaks. So read carefully every upgrade document for necessary code changes.
from 2.0 to 2.1
from 2.1 to 2.2
from 2.2 to 2.3

Related

assert error in symfony/translations when dumping translations

I have recently updated my project from symfony 6.1 to symfony 6.2 and I'm experiencing issue while dumping translations
commend that I use:
bin/console translation:extract pl --force --format=yaml
results in:
exception trace points to
vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php:36
I've already updated all packages, especially symfont/translation to version 6.2.*
For now, only downgrading symfony back to 6.1 solves this for me.
This issue has been fixed in symfony 6.2.2. You can update your project and try again.
It has been resolved in my projects.
composer update "symfony/*"

symfony 4.4 + sonata deprecations like sonata.deprecated_text.twig.extension | sonata.twig.deprecated_template_extension

I've installed sonata + symfony 4.4 on new clean empty project.
Did everything according to https://symfony.com/doc/current/bundles/SonataAdminBundle/getting_started/installation.html
and executed the recipes , composer adviced me to apply.
But on pristine setup I'm having a few deprecations like:
User Deprecated: The "sonata.twig.deprecated_template_extension"
service is deprecated since sonata-project/twig-extensions 1.4.
User Deprecated: The "sonata.deprecated_text.twig.extension" service
is deprecated since sonata-project/admin-bundle 3.70. You should stop
using it, as it will be removed in 4.0.
The child node "legacy_twig_text_extension" at path
"sonata_admin.options" is deprecated since sonata-project/admin-bundle
3.70 and will be removed in 4.0.
Is it ok? I don't have any legacy I've just set up compeltely new project?
Can I somehow avoid these deprecations or is it just an expected behavior and I have to get used to it?

Install twig/extensions on a Symfony 4 or Symfony 5 new project

I'm preparing to migrate a huge website from Symfony 3.4 to Symfony 4.4.
To do this, I'm starting from a new fresh installation of Symfony 4.4, and as the intial project requires the use of Twig Extensions I try to install it on this new Symfony 4.4 project.
But composer indicates Your requirements could not be resolved to an installable set of packages.
The error message is obvious, but I don't understand why this situation happens on a fresh symfony 4.4 project.
What I tried :
I create a new Symfony symfony new --full --version=lts testproject that installed Symfony 4.4 and right after composer require twig/extensions => Your requirements could not be resolved to an installable set of packages.
I create a new Symfony symfony new --full testproject that installed Symfony 5.0 and right after composer require twig/extensions => Your requirements could not be resolved to an installable set of packages.
I tried with Symfony flex but same problem => Your requirements could not be resolved to an installable set of packages.
I retried after clearing the composer cache but no change.
This worked :
- I create a new Symfony symfony new --full --version=3.4 testproject that installed Symfony 3.4 and right after composer require twig/extensions => OK
I understand that dependencies conflits occur for Symfony 4.4 and more, but according to Symfony doc How to Write a custom Twig Extension no further actions are required and it should work.
What I'm missing ? Does someone faced the same problem ? Thanks
if you're using Flex, you should install twig first:
composer req twig
then, do:
composer require twig/extensions
I hope that help.
Finally it seems that running composer require twig/extensions is no more required to create custom Twig Extensions in Symfony 4.
By default a new Symfony built with website skeleton owes a use Twig\Extension\AbstractExtension; as per required to create a twig extension like below one :
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class AppExtension extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('price', [$this, 'formatPrice']),
];
}
public function formatPrice($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
{
$price = number_format($number, $decimals, $decPoint, $thousandsSep);
$price = '$'.$price;
return $price;
}
}

can't install eventdispatcher2.8 on symfony 3.3

i'm trying to install omnypay in symfony 3.3 and i found that i must install the
eventdispatcher:^2.8 before
using :
composer require symfony/event-dispatcher:^2.8
but i got error:
[InvalidArgumentException]
The service "resolve_controller_name_subscriber" must be public as event subscribers are lazy-loaded.
i changed the class (resolve_controller_name_subscriber) to be public and the problem is resolved but i'm not sure if this is the right way

FOSRestBundle & JMSSerializerBundle with symfony 2.7 and PHP 5.5.12

I'd like to add the 2 libraries FOSRestBundle & JMSSerializerBundle to my application built with symfony 2.7 but i encountred this response
Problem 1
- Installation request for friendsofsymfony/rest-bundle dev-master -> satisfiable by friendsofsymfony/rest-bundle[dev-master].
- friendsofsymfony/rest-bundle dev-master requires php ^5.5.9|~7.0 -> your PHP version (5.5.12) overriden by "config.platform.php" version (5.3.9) does not satisfy that requirement.
Problem 2
- Installation request for jms/serializer-bundle dev-master -> satisfiable by jms/serializer-bundle[dev-master].
- jms/serializer-bundle dev-master requires php >=5.4.0 -> your PHP version (5.5.12) overriden by "config.platform.php" version (5.3.9) does not satisfy that requirement.
Notice that PHP version is 5.5.12
I think the problem is the version of this 2 libraries. If yes, What are the versions of FOSRestBundle & JMSSerializerBundle ?
dev-master should never be used as version bound when requiring a package as dependency, except in some specific cases.
Go to https://packagist.org/ then search for the packages you are looking for and use their respective current stable version as version bound for your composer.json's requirement.
Also, in your composer.json, you have a config key containing a platform.php key with 5.3.9 as value. Remove or override this block according to your real PHP version. See Symfony2, composer, your PHP version (5.6.18) overriden by "config.platform.php" version (5.3.9) does not satisfy requirement.
Of course, if the last stable version of one of them isn't compatible with your environment (PHP >= 5.5.9 for friendsofsymfony/rest-bundle), you need to look for an older version supporting your environment (all is available on packagist, and surely on the official documentation of these packages).

Resources