havvg's playground

Developing Software is Fun!

share user class among apps within one symfony project

Toni Uebernickel

Is it possible to share one user class among all apps within one symfony project? - Yes, it is! It is very easy, too. All you need is - surprisingly - a class, some changes in the factories.yml of the apps sharing the user class and that’s it!

At first create a user class you want to share and save it e.g. in lib/mcxUser.class.php, for example:

<?php
class mcxUser extends sfGuardSecurityUser
{
  // your code here
}

Now all that’s left is the factories.yml. Add these lines to the factories.yml in the all: section within all apps that will be using the shared user class.

user:
  class: mcxUser
  param:
    timeout:         1800
    logging:         %SF_LOGGING_ENABLED%
    use_flash:       true
    default_culture: %SF_DEFAULT_CULTURE%

Having done this, you have a green to go. Make sure you clear the cache after doing this.

blog comments powered by Disqus
Written by

Toni Uebernickel

Software Engineer and Architect, Symfony evangelist with some Ducati bikes.

Support & Share
You should subscribe to my feed!
All content copyright Toni Uebernickel © 2017 • All rights reserved.