Weave 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

Maker Bundle Laravel Package

drosalys/maker-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation

    composer require drosalys/maker-bundle
    

    Register the bundle in config/bundles.php (Symfony) or ensure it’s auto-discovered in Laravel (if ported).

  2. First Use Case Run a basic command to generate a scaffold:

    php artisan make:bundle-scaffold User
    

    This creates a CRUD structure for a User entity with:

    • Controller (UserController)
    • Repository (UserRepository)
    • Service (UserService)
    • DTOs (Data Transfer Objects)
    • Migrations (if --with-migration flag is used)
    • Tests (if --with-tests flag is used)
  3. Where to Look First

    • Command Reference: Run php artisan to see available make:bundle-* commands.
    • Templates: Check vendor/drosalys/maker-bundle/src/Resources/skeleton/ for default templates.
    • Configuration: Override defaults in config/maker-bundle.php (if available).

Implementation Patterns

Core Workflows

  1. Scaffold Generation Use make:bundle-scaffold for full-stack CRUD:

    php artisan make:bundle-scaffold Post --with-migration --with-tests --api
    
    • --api: Generates API-specific routes/controllers.
    • --with-validation: Adds request validation rules.
  2. Modular Extensions Generate isolated components:

    php artisan make:bundle-controller Admin/UserController
    php artisan make:bundle-repository UserRepository
    php artisan make:bundle-service UserService
    
  3. Custom Templates Override default templates by copying skeleton files to:

    resources/maker-bundle/skeleton/
    

    Example: Modify controller.stub to add custom methods.

  4. Integration with Existing Code

    • Repositories: Extend BaseRepository to add custom query methods.
      class UserRepository extends BaseRepository
      {
          public function activeUsers()
          {
              return $this->model->where('active', true);
          }
      }
      
    • Services: Inject repositories into services for business logic.
      class UserService
      {
          public function __construct(private UserRepository $repository) {}
      
          public function getActiveUsers()
          {
              return $this->repository->activeUsers()->get();
          }
      }
      
  5. API Resources Generate API resources with:

    php artisan make:bundle-api-resource UserResource
    

    Customize fields in UserResource.php:

    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'email' => $this->email,
        ];
    }
    
  6. Testing Use --with-tests to generate PHPUnit tests. Extend with custom assertions:

    public function testCreateUser()
    {
        $response = $this->post('/api/users', ['name' => 'Test']);
        $response->assertCreated();
        $this->assertDatabaseHas('users', ['name' => 'Test']);
    }
    

Gotchas and Tips

Pitfalls

  1. Namespace Conflicts

    • Ensure generated classes don’t clash with existing namespaces. Use --namespace flag:
      php artisan make:bundle-service UserService --namespace=App\Services\Admin
      
  2. Migration Overwrites

    • Regenerating migrations with --with-migration may overwrite existing ones. Backup first or use --force cautiously.
  3. Stub File Overrides

    • Custom stubs in resources/maker-bundle/skeleton/ must match the original structure exactly. Misspelled placeholders (e.g., {{= }} vs {{ }}) will break generation.
  4. Laravel-Specific Quirks

    • If using in Laravel (not Symfony), some Symfony-specific features (e.g., Bundle classes) may need adaptation. Replace Bundle with ServiceProvider or remove unused traits.
  5. Dependency Injection

    • Services/repositories generated by the bundle assume Laravel’s container. For manual instantiation, bind them in AppServiceProvider:
      $this->app->bind(UserRepository::class, function ($app) {
          return new UserRepository(new User());
      });
      

Debugging

  1. Command Output Run with -vvv for verbose output:

    php artisan make:bundle-scaffold User -vvv
    

    Helps identify template rendering issues.

  2. Template Debugging Add {{ dump($) }} to stub files to inspect variables during generation.

  3. Cache Issues Clear Laravel’s command cache if changes to stubs aren’t reflected:

    php artisan cache:clear
    

Tips

  1. Partial Generation Generate only what you need to avoid clutter:

    php artisan make:bundle-controller UserController --no-repository --no-service
    
  2. Reusable Config Define default options in config/maker-bundle.php (if supported):

    'default_namespace' => 'App\\Bundles',
    'use_api_resources' => true,
    
  3. Post-Generation Hooks Use Laravel’s generated:bundle event (if supported) to run post-processing:

    // In EventServiceProvider
    protected $listen = [
        'generated:bundle' => [
            'App\Listeners\PostBundleGeneration',
        ],
    ];
    
  4. Documentation Since the package lacks formal docs, explore:

    • GitLab issues for common use cases.
    • Example bundles in the tests/ directory of the package.
  5. Performance For large projects, generate bundles in batches to avoid long build times. Example:

    php artisan make:bundle-scaffold Post --no-tests
    php artisan make:bundle-tests Post
    
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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib