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

Symfony 4 support #318

Closed
Gemorroj opened this issue Jan 17, 2018 · 27 comments
Closed

Symfony 4 support #318

Gemorroj opened this issue Jan 17, 2018 · 27 comments

Comments

@Gemorroj
Copy link
Contributor

Need add Symfony 4 support

@hex333ham
Copy link
Collaborator

hex333ham commented Jan 22, 2018

For anyone who's interested, I've got the bundle working in Symfony 4 in a very 'hacky' way.
Good for a short-term patch/solution.

See the basic installation instructions on how to get bundle overrides for templates working in Symfony 4 with this, that was the only major hurdle I had after changing the installation requirements and renaming template locations to match Symfony 4.

https://github.com/hex333ham/FOSMessageBundle/tree/symfony4

@kubaceg
Copy link

kubaceg commented Jan 30, 2018

I need it too :) Hacky way from @hairybobbins don't work for me, composer can't resolve paths.

@hex333ham
Copy link
Collaborator

hex333ham commented Jan 30, 2018

@kubaceg Can you post the full error message from composer please?

@kubaceg
Copy link

kubaceg commented Jan 30, 2018

Hi, from user entity

Fatal error: Interface 'FOS\MessageBundle\Model\ParticipantInterface' not found in /var/www/symfony/src/Entity/User/User.php on line 10

I'm thinking now that probably after my changes in composer.json (repository + new bundle) and composer install command nothing happens. I must check it once again

@hex333ham
Copy link
Collaborator

@kubaceg It looks to me like your application is failing before it reaches composer, it might be worth commenting out that reference then seeing if it works.

@hex333ham
Copy link
Collaborator

hex333ham commented Mar 13, 2018

@kubaceg hey, just realised that target-dir was accidentally removed in the composer.json file due to the deprecation of psr-0, this means that if you move the hacky versions code under the correct directory structure within the bundle (FOS\MessageBundle) it will work.

If anyone knows of a way to fix this please let me know, I'll be researching the problem but I am not the best when it comes to composer.

if you're experiencing issues, run composer require friendsofsymfony/message-bundle:dev-symfony4, this will reload the package and has fixed all issues on my end

@kubaceg
Copy link

kubaceg commented Mar 14, 2018

Thanks! I'll try it :)

@kubaceg
Copy link

kubaceg commented Mar 18, 2018

It works fine :) only what I have to do was add own entities mapping in yaml + define aliases:

    fos_user.user_to_username_transformer:
        alias: App\Service\UserToUsernameTransformer

    FOS\MessageBundle\Composer\Composer: '@fos_message.composer'

    FOS\MessageBundle\Sender\Sender: '@fos_message.sender'

@hex333ham
Copy link
Collaborator

hex333ham commented Apr 3, 2018

@kubaceg good spot, I'll add these notes to the install instructions on my fork later

cheers!

@afranioce
Copy link
Contributor

@hairybobbins I'm using your fork but it's giving the service error

The "fos_message.provider" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

@afranioce
Copy link
Contributor

afranioce commented Apr 6, 2018

It ran when I put the services as public in the class FOS\MessageBundle\DependencyInjection\FOSMessageExtension.php

Ex.:

class FOSMessageExtension extends Extension
{
//...
    $container->setAlias('fos_message.message_manager', new Alias($config['message_manager'], true));
//...
}

https://pastebin.com/1LWseFuu

@ChanOmegaWebDesign
Copy link

@hairybobbins I just submitted a pull request to your fork implementing the fix by @afranioce for all the Aliases.

@phtmgt
Copy link

phtmgt commented Apr 20, 2018

Thanks for all the suggestions. I used these to get the bundle to work, but now I can't get it to use my custom twig templates. In Symfony 4 they should be placed in /templates/bundles/... Unfortunately, this does not work at all. Any suggestions?

@ChanOmegaWebDesign
Copy link

ChanOmegaWebDesign commented Apr 20, 2018

capture
@finkbg This works for me, edit "templates/bundles/FOSMessageBundle/layout.html.twig" to extend your base template. Then change the extends path in the other files (templates/bundles/FOSMessageBundle/Message/.) to
{% extends 'bundles/FOSMessageBundle/layout.html.twig' %}
What errors are you getting?

@ChanOmegaWebDesign
Copy link

@finkbg Also make sure to tell twig about the path (last step from "~/vendor/friendsofsymfony/message-bundle/FOS/MessageBundle/Resources/doc/01-installation.md")

# ~/config/packages/twig.yaml
twig:
  paths:[
    '%kernel.project_dir%/templates',
    '%kernel.project_dir%/templates/bundles/FOSMessageBundle': FOSMessageBundle
  ]

@hex333ham
Copy link
Collaborator

hex333ham commented Apr 20, 2018

Just seen this thread guys (really wish github had a notifications bar, or if it does I wish I could find it :') )

I've got some time free next monday and over the weekend, so I'll have a look at the fixes you've both suggested @ChanOmegaWebDesign @afranioce

Cheers!

@phtmgt
Copy link

phtmgt commented Apr 21, 2018

@ChanOmegaWebDesign Thanks, changing the extend path worked for me. For whatever reason (3.4 legacy?) the extend path in the files was FOSMessageBundle::layout.html.twig and it pointed at the vendor path instead of templates/bundles/....

@hex333ham
Copy link
Collaborator

hex333ham commented Apr 25, 2018

Pull request now approved and merged @ChanOmegaWebDesign

@hex333ham
Copy link
Collaborator

@finkbg Can you provide us with your Message entity?

The only suggestion I can offer without that is to make sure you've included use FOS\MessageBundle\Entity\Message as BaseMessage; at the top of your entity, then made sure that the Message entity extends this class Message extends BaseMessage

@hex333ham
Copy link
Collaborator

@finkbg as @kubaceg has mentioned previously, you might also need to map your entities in your config file

@phtmgt
Copy link

phtmgt commented May 22, 2018

I accidentally deleted the original post:

Basically, it said that the App/Entities did not work. Actually, they are working, we were wrongly trying to use a setter when initially creating the thread with $composer->newThread(). This seems a bit confusing, as $composer->newThread() returns an instance of Entity/Message instead of Entity/Thread. We figured it out.

However, we are having a separate issue when serializing the Thread Entity with JMS Serializer. For some reason the @expose rules in the App/Entity/Thread are being ignored.

@GuilhemN
Copy link
Member

@hairybobbins would you like to take over this bundle's maintainance? I actualized things a bit in #329 but I won't be able to do much more...

Otherwise without a maintainer we will likely deprecate this bundle :/

@GuilhemN
Copy link
Member

Symfony 4 support added in #329 😄

@hex333ham
Copy link
Collaborator

@GuilhemN hey man, completely missed this e-mail

happy to take over maintenance of the bundle (if the offer is still available) as there are some mods I've made to a project of mine that might be handy to the bundle in general

@hex333ham
Copy link
Collaborator

Also to everyone using my fork, I've changed my username to hex333ham (professional reasons), make sure to update your composer accordingly

@GuilhemN
Copy link
Member

No problem, the offer is still available of course ;)
I sent you an invitation, thanks for taking care of this bundle!

@methodeprog
Copy link

Great bundle sûre i will give a try.

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

8 participants