Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Symfony3 #64

Closed
anthonyherve opened this issue Mar 1, 2016 · 20 comments
Closed

Compatibility with Symfony3 #64

anthonyherve opened this issue Mar 1, 2016 · 20 comments

Comments

@anthonyherve
Copy link
Contributor

No description provided.

@antonskv
Copy link

antonskv commented Mar 1, 2016

I also looked into upgrading to Sym3.0 and this issue of deprecated code came from the check-list for upgrade.

Profiler shows this message:
"DEPRECATED - Defining the getGlobals() method in the "comur_thumb_extension" extension without explicitly implementing Twig_Extension_GlobalsInterface is deprecated since version 1.23"

I looked around and found that this should be an easy fix. I think the deprecated message comes from Twig extension class: /vendor/comur/image-bundle/Comur/ImageBundle/Twig/ThumbExtension.php

Line #4:
class ThumbExtension extends \Twig_Extension

Change to:
class ThumbExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface

And /vendor/comur/image-bundle/Comur/ImageBundle/Resources/config/routing.yml syntax needs to change "pattern: " to "path: ".

I hope it's an only thing that needs to be done for this bundle to be Sym3.0 compliant.

@comur
Copy link
Owner

comur commented Mar 1, 2016

Hi,
Thanks for this investment. Can someone check it on SF3 ? I don't have yet any project on SF3

@antonskv
Copy link

antonskv commented Mar 1, 2016

@comur I never done major version upgrade for Symfony, so i'm still in process resolving all of my own code before getting it to work and some 3rd party bundles which are also pending update. But i'll write when i get it to work and i'll let you know the results.

@anthonyherve
Copy link
Contributor Author

Hi,
Here a first list of deprecated calls using Symfony 2.8

  • The "pattern" option in file "/srv/www/symfony28/vendor/comur/image-bundle/Comur/ImageBundle/Resources/config/routing.yml" is deprecated since version 2.2 and will be removed in 3.0. Use the "path" option in the route definition instead. (3 times) Show stack trace
  • Comur\ImageBundle\Form\Type\CroppableImageType: The FormTypeInterface::getName() method is deprecated since version 2.8 and will be removed in 3.0. Remove it from your classes. Use getBlockPrefix() if you want to customize the template block prefix. This method will be added to the FormTypeInterface with Symfony 3.0. Show stack trace
  • Accessing type "comur_image" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "Comur\ImageBundle\Form\Type\CroppableImageType" instead. Show stack trace
  • The Symfony\Component\OptionsResolver\OptionsResolver::setNormalizers method is deprecated since version 2.6 and will be removed in 3.0. Use setNormalizer() instead. Show stack trace
  • Comur\ImageBundle\Form\Type\CroppableImageType: The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0. Show stack trace
  • Accessing type "text" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "Symfony\Component\Form\Extension\Core\Type\TextType" instead. Show stack trace
  • Defining the getGlobals() method in the "comur_thumb_extension" extension without explicitly implementing Twig_Extension_GlobalsInterface is deprecated since version 1.23. Show stack trace

I'll try to fork project and correct these calls.

@anthonyherve
Copy link
Contributor Author

I just created a pull request for compatibility : #65
I let you check if it's ok for you. :-)

Thanks.

@antonskv
Copy link

antonskv commented Mar 4, 2016

@anthonyherve oooh, nice work dude. thumbs up

@comur
Copy link
Owner

comur commented Mar 7, 2016

@anthonyherve thanks for this work !
@antonskv do you have time and ability to check it on a SF3 project ?

Thanks again, i will try to look ASAP and merge it.

@anthonyherve
Copy link
Contributor Author

I'm checking it on a SF3 project, but I have a little problem with version of jms/translation-bundle. The last stable version of this bundle is not compliant with SF3. So I put dev-master, but I have following problem :
"Invalid resource provided: "1.2"; Errors: [ERROR 1845] Element '{urn:jms:translation}reference-file': No matching global element declaration available, but demanded by the strict wildcard.

Have you already saw this problem ?

@antonskv
Copy link

antonskv commented Mar 7, 2016

@comur I'll try to find time to start fresh AWS instance and maybe do a clean Symfony 3.0 install and add your bundle + anthonys changes from the fork. I cant get composer through update with Symfony 3.0, as mentioned above there is a whole load of 3rd party bundles which are not up to date. Our main server still runs on PHP 5.4.x, i cant even test on it.

@anthonyherve Do you have translation bundle enabled inside Dev?

I think this causes it:

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    // ...
    $bundles[] = new JMS\TranslationBundle\JMSTranslationBundle();
    // ...
}

Source: schmittjoh/JMSTranslationBundle#169

Also PHP version constraint in composer... I think that expression ::class, for resolving class names has only been added in PHP 5.5, my NetBeans pointed that out.

Source: http://php.net/manual/en/migration55.new-features.php

@antonskv
Copy link

OK i have a AWS instance with clean PHP 5.7 and Symfony 3.0, i can just do a basic tests.

I dont mean sound stupid, but doing composer update won't work, since anothony's code is in separate bundle. I there i fancier way than just grabbing a zipball of his fork and dropping it in?

@anthonyherve
Copy link
Contributor Author

Cool news !
For your tests, I think you can clone my fork repo and add a local repo in your composer dependencies (read this article : http://marekkalnik.tumblr.com/post/22929686367/composer-installing-package-from-local-git).
Mayve you have to add "minimum-stability": "dev" in your composer.json for JMSTranslationBundle that is not stable yet.

Good luck !

I'm waiting for your answer. :-)

@anthonyherve
Copy link
Contributor Author

We have to add "prefer-stable" : true in composer.json to avoid downloading all dev versions of dependencies.
I corrected something in CroppableImageType : use setNormalizer method instead of setNormalizers.
For translations, I have same error. I have a solution but I'm not sur I can do it. It's to delete in all translation's files line jms:reference-file and xmlns:jms="urn:jms:translation" line 2.
Do you think I can do it ?

Thanks.

@comur
Copy link
Owner

comur commented Mar 14, 2016

Hi, i will create a new branch for compatibility with SF3.
For translations, we can regenerate them all in command line to have a proper copy.

@anthonyherve
Copy link
Contributor Author

I tried to regenerate with command, but I have errors with JMSTranslationBundle. Can you try it on your side with branch symfony3 of my fork ?
Thanks.

@antonskv
Copy link

@anthonyherve Does this run successfully? *bin/console translation:update en ComurImageBundle --force --output-format xlf *

This Symfony 3 is a major pain in the butt, i cant even partially transfer our dev site to Symfony 3. I think i just code fresh controller, Entity and fresh Symfony form to test this. I can't get anything to work, 'cause one 3rd party bundle catches on other and they all have non-compatible dependencies.

I mean i added your fork on clean Sym3 install, and initial page comes up fine, clearing cache works. Services are included and no red flags coming up.

bash-3.2# bin/console debug:container | grep comur
  comur.twig.thumb_extension                                           Comur\ImageBundle\Twig\ThumbExtension                                                       
  comur_image_bundle.gallery_type                                      Comur\ImageBundle\Form\Type\CroppableGalleryType                                            
  comur_image_bundle.image_type                                        Comur\ImageBundle\Form\Type\CroppableImageType                                              
bash-3.2# 

Composer lock file shows that ComurImageBundle is from local git (your cloned fork), so it at least installs and Symfony 3 is running.

"packages": [
        {
            "name": "comur/image-bundle",
            "version": "dev-master",
            "target-dir": "Comur/ImageBundle",
            "source": {
                "type": "git",
                "url": "/Users/anton/repositories_temp/ComurImageBundle",  <--------------
                "reference": "f149cfc9620626bce9d236d5c961e6c7813f5662"
            },
            "require": {
                "ext-gd": "*",
                "friendsofsymfony/jsrouting-bundle": "@stable",
                "jms/translation-bundle": "dev-master",
                "php": ">=5.3.2",
                "symfony/class-loader": "~2.2|3.*",
                "symfony/config": "~2.2|3.*",
                "symfony/form": "~2.2|3.*",
                "symfony/http-foundation": "~2.2|3.*",
                "symfony/routing": "~2.2|3.*",
                "symfony/twig-bridge": "~2.2|3.*",
                "symfony/validator": "~2.2|3.*",
                "twig/extensions": "~1.0",
                "twig/twig": "~1.12"
            },
            "type": "symfony-bundle",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.0-dev"
                }
            },
            "autoload": {
                "psr-0": {
                    "Comur\\ImageBundle": ""
                }
            },
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Can OMUR",
                    "email": "omur.can@gmail.com",
                    "homepage": "http://canomur.com"
                }
            ],
            "description": "A bundle providing fields for image upload with jquery upload and image cropping with jcrop for symfony2",
            "homepage": "https://github.com/comur/ComurImageBundle",
            "keywords": [
                "Form Type",
                "crop",
                "image",
                "jcrop",
                "jquery upload",
                "upload"
            ],
            "time": "2016-03-13 17:02:23"
        },

Just to verify the GIT is actually your fork:

bash-3.2# pwd
/Users/anton/repositories_temp/ComurImageBundle
bash-3.2# git log --name-status HEAD^..HEAD
commit 53afe425a449f1e657eee8b36668bfdfb47c36ce
Author: anthonyherve <anthony.herve28@gmail.com>
Date:   Sun Mar 13 18:15:52 2016 +0100

    Edit french translation

M       Resources/translations/ComurImageBundle.fr.xliff
bash-3.2# 

Profiler shows ComurBundle enabled and working. Assets are getting installed too:

bash-3.2# bin/console assets:install
Installing assets as hard copies.

 --- ------------------ ---------------- 
      Bundle             Method / Error  
 --- ------------------ ---------------- 
  ✔   FrameworkBundle    copy            
  ✔   ComurImageBundle   copy            
 --- ------------------ ---------------- 

 ! [NOTE] Some assets were installed via copy. If you make changes to these assets you have to run this command again.  

 [OK] All assets were successfully installed.                                    

So i don't know, seems ok. To be honest i'd love to test it by ACTUALLY using it with Entities and Forms, but can't find a free night to code a basic fresh code using it.

@joskewie
Copy link

Anyone got this bundle working with symfony3?
I used the 1.3 branch, and followed regular installation instructions but still got a: Could not load type "comur_image" error in my formbuilder...

@comur
Copy link
Owner

comur commented Jun 23, 2016

Hi @joskewie
You need to use
->add('image', CroppableImageType::class, array(...
as described in 1.3 readme

@joskewie
Copy link

aha thanks! checked the wrong readme indeed, works now

@glerendegui
Copy link

There's still a bug at https://github.com/comur/ComurImageBundle/blob/1.3/Form/Type/CroppableImageType.php line 44.
'text' must be changed to TextType::class as in line 49

@comur
Copy link
Owner

comur commented May 30, 2019

Please check with last release

@comur comur closed this as completed May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants