Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

User Bundle Laravel Package

ekyna/user-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle to your composer.json:

    composer require ekyna/user-bundle
    

    Register in config/bundles.php:

    Ekyna\UserBundle\EkynaUserBundle::class => ['all' => true],
    
  2. Database Migration Run migrations (if provided) or manually create tables based on FOSUserBundle schema (this bundle extends it). Key tables:

    • fos_user (core user data)
    • fos_user_group (groups/roles)
    • ekyna_user_profile (extended profile fields)
  3. First Use Case: User Registration Extend the default FOSUser registration controller or use Ekyna’s admin interface (if EkynaAdminBundle is integrated):

    // routes.yaml
    ekyna_user_registration_register: ~
    

    Test registration at /register (default route).


Implementation Patterns

Core Workflows

  1. User CRUD via AdminBundle If EkynaAdminBundle is installed, users/groups are managed via its UI. Example admin config:

    # config/packages/ekyna_admin.yaml
    ekyna_admin:
        resources:
            Ekyna\UserBundle\Entity\User:
                list: [id, username, email, enabled]
                edit: [username, email, groups]
    
  2. Profile Extension Extend User entity with custom fields (e.g., profile):

    // src/Entity/User.php
    /**
     * @ORM\OneToOne(targetEntity="Ekyna\UserBundle\Entity\UserProfile", mappedBy="user", cascade={"persist", "remove"})
     */
    private $profile;
    
  3. Authentication Use Symfony’s security system with FOSUserBundle’s providers:

    # config/packages/security.yaml
    security:
        providers:
            fos_userbundle:
                id: fos_user.user_provider.username_email
    
  4. API Integration Serialize user data for APIs (e.g., with API Platform or custom serializers):

    use Ekyna\UserBundle\Entity\User;
    use Symfony\Component\Serializer\Annotation\Groups;
    
    class User implements \Serializable {
        /**
         * @Groups({"api"})
         */
        public function getFullName() { ... }
    }
    

Integration Tips

  • Event Listeners: Hook into FOSUserBundle events (e.g., UserRegisteredEvent) for post-registration logic:
    // src/EventListener/UserListener.php
    public function onUserRegistered(UserRegisteredEvent $event) {
        $user = $event->getUser();
        $user->setProfile(new UserProfile());
        $this->entityManager->persist($user);
    }
    
  • Validation: Override FOSUserBundle’s validation constraints in your User entity.
  • Routing: Customize routes by extending the bundle’s routing loader or overriding templates in templates/EkynaUserBundle/.

Gotchas and Tips

Pitfalls

  1. Deprecated Dependencies

    • The bundle relies on FOSUserBundle (last updated 2018) and EkynaAdminBundle (abandoned). Test thoroughly with Symfony 5/6.
    • Libphonenumber bug: Validate phone numbers manually if using Ekyna\UserBundle\Form\Type\PhoneType (e.g., with symfony/validator constraints).
  2. Translation Issues

    • Override translations in translations/messages.en.yaml to replace FOSUserBundle’s username-based labels:
      'user.username.label': 'Email Address'
      
  3. Routing Conflicts

    • Default routes (e.g., /account/) may clash with other bundles. Override in config/routes.yaml:
      ekyna_user:
          resource: "@EkynaUserBundle/Resources/config/routing.yml"
          prefix: /user
      
  4. AdminBundle Dependency

    • Without EkynaAdminBundle, user management falls back to FOSUserBundle’s templates (deprecated). Use make:controller to build custom admin routes.

Debugging Tips

  • Entity Mapping: Verify associations (e.g., UserProfile) are correctly mapped in User.php:
    // Ensure bidirectional relationships
    $profile->setUser($this);
    $this->profile = $profile;
    
  • Permissions: Debug role/group issues with:
    php bin/console debug:security
    
  • Form Errors: Clear cache after extending forms:
    php bin/console cache:clear
    

Extension Points

  1. Custom Fields Add fields to UserProfile entity and update the form type (Ekyna\UserBundle\Form\Type\UserProfileType).

  2. Email Templates Override Twig templates in templates/EkynaUserBundle/Email/ (e.g., registration.html.twig).

  3. API Tokens Integrate with lexik/jwt-authentication-bundle for token-based auth:

    # config/packages/security.yaml
    firewalls:
        api:
            pattern: ^/api
            stateless: true
            jwt: ~
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager