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 Profile Bundle Laravel Package

crisistextline/user-profile-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Run composer require crisistextline/user-profile-bundle in your Laravel project (note: this bundle is Symfony-based, but can be adapted for Laravel via bridge packages like symfony/console or symfony/dependency-injection if needed).

  2. Bundle Registration Add the bundle to your config/app.php under providers (Laravel) or AppKernel.php (Symfony):

    'providers' => [
        // ...
        CrisisTextLine\UserProfileBundle\CrisisTextLineUserProfileBundle::class,
    ],
    
  3. Routing Define routes in routes/web.php (Laravel) or routing.yml (Symfony):

    Route::prefix('/')->group(function () {
        Route::resource('user-profile', 'CrisisTextLine\UserProfileBundle\Controller\UserProfileController');
    });
    
  4. User Entity Configuration Configure the bundle to resolve your Laravel User model (e.g., App\Models\User) in config/services.php:

    'user-profile' => [
        'entity' => App\Models\User::class,
    ],
    
  5. First Use Case Trigger the bundle’s default controller actions (e.g., GET /user-profile) to verify CRUD operations for user profiles.


Implementation Patterns

Usage Patterns

  1. Profile Management Extend the bundle’s UserProfileController to handle custom profile fields (e.g., crisis-related metadata):

    // app/Http/Controllers/UserProfileController.php
    namespace App\Http\Controllers;
    
    use CrisisTextLine\UserProfileBundle\Controller\UserProfileController as BaseController;
    
    class UserProfileController extends BaseController
    {
        public function show($id)
        {
            $profile = $this->getUserProfile($id);
            return view('user.profile', compact('profile'));
        }
    }
    
  2. Form Integration Use the bundle’s form types (if available) or create custom forms in Laravel’s Form facade:

    use Illuminate\Support\Facades\Form;
    
    $form = Form::model($user, [
        'method' => 'PUT',
        'url' => route('user-profile.update', $user->id)
    ]);
    
  3. Event Listeners Hook into user profile events (e.g., profile.created) via Laravel’s event system:

    // app/Providers/EventServiceProvider.php
    protected $listen = [
        'CrisisTextLine\UserProfileBundle\Events\ProfileCreated' => [
            'App\Listeners\LogProfileActivity',
        ],
    ];
    
  4. API Integration Expose profile endpoints via Laravel’s API resources:

    Route::apiResource('api/profiles', 'Api\UserProfileController');
    

Workflows

  • Crisis-Specific Profiles: Extend the User model to include crisis-related fields (e.g., crisis_level, support_history).
  • Validation: Use Laravel’s validation rules to enforce profile constraints:
    $validator = Validator::make($request->all(), [
        'crisis_level' => 'required|integer|between:1,5',
    ]);
    
  • Authentication: Secure routes with Laravel’s middleware:
    Route::middleware(['auth'])->group(function () {
        Route::resource('user-profile', 'UserProfileController');
    });
    

Integration Tips

  • Doctrine ORM Bridge: If using Doctrine, install laravel-doctrine/orm to bridge Laravel’s Eloquent with Doctrine entities.
  • Symfony Components: Leverage Symfony’s Validator, Form, or Serializer components via Laravel’s service container.
  • Testing: Use Laravel’s HttpTests to test profile routes:
    $response = $this->get('/user-profile/1');
    $response->assertStatus(200);
    

Gotchas and Tips

Pitfalls

  1. Symfony vs. Laravel Mismatch

    • The bundle assumes Symfony’s Kernel, DependencyInjection, and Doctrine setup. Use bridge packages (e.g., symfony/console-bridge) or rewrite controllers/services for Laravel.
    • Fix: Override bundle classes or create Laravel-specific adapters.
  2. Outdated Dependencies

    • Last release in 2016 may conflict with modern Laravel (v9+) or PHP (v8+).
    • Fix: Fork the repo and update dependencies (e.g., symfony/*, doctrine/*).
  3. Hardcoded Routes/Config

    • The bundle expects specific route prefixes (/) and config keys (crisis_text_line_user_profile).
    • Fix: Override routes/config in Laravel’s boot() or register() methods.
  4. No Eloquent Support

    • The bundle uses Doctrine ORM by default. For Eloquent, create a custom repository:
    // app/Repositories/UserProfileRepository.php
    class UserProfileRepository {
        public function find($id) {
            return User::find($id);
        }
    }
    

Debugging

  • Route Conflicts: Use php artisan route:list to check for overlaps with Laravel’s default routes.
  • Dependency Errors: Clear Laravel’s cache (php artisan cache:clear) and config (php artisan config:clear) after bundle changes.
  • Entity Resolution: Verify the user-profile.entity config points to a valid Laravel model:
    // config/services.php
    'user-profile' => [
        'entity' => App\Models\User::class, // Must exist
    ],
    

Tips

  1. Custom Controllers Replace the bundle’s controller with a Laravel-specific one:

    // app/Http/Controllers/UserProfileController.php
    class UserProfileController extends Controller {
        public function index() {
            return User::all();
        }
    }
    
  2. Profile Extensions Add crisis-specific fields to the User model:

    // app/Models/User.php
    class User extends Authenticatable {
        protected $fillable = ['name', 'crisis_level', 'last_contacted_at'];
    }
    
  3. API Resources Format profile data for APIs:

    // app/Http/Resources/UserProfileResource.php
    class UserProfileResource extends JsonResource {
        public function toArray($request) {
            return [
                'id' => $this->id,
                'crisis_level' => $this->crisis_level,
                'created_at' => $this->created_at->toDateTimeString(),
            ];
        }
    }
    
  4. Testing Mock the bundle’s services in Laravel’s AppServiceProvider:

    public function register() {
        $this->app->bind(
            'crisis_text_line.user_profile.manager',
            function () {
                return new \App\Services\UserProfileManager();
            }
        );
    }
    
  5. Legacy Workarounds For Symfony-specific features (e.g., Twig templates), use Laravel’s Blade or Symfony\Bridge\Twig\Extension\RoutingExtension:

    // config/app.php
    'view' => [
        'composer' => [
            'App\View\Composers\ProfileComposer',
        ],
    ],
    
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware