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

c33s/maker-extra-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Add the package via Composer in your Laravel project:

    composer require c33s/maker-extra-bundle
    

    Ensure the package is registered in config/app.php under the extra key in the makers array (if using Symfony Maker Bundle) or run:

    php artisan maker:install
    
  2. First Use Case Generate a CRUD controller with API resources (a common Laravel workflow):

    php artisan make:crud Post --api
    

    This creates a controller, repository, service, and API resource in one command.

  3. Where to Look First

    • Documentation: Check the GitLab repository for available makers and options.
    • Command List: Run php artisan to see all available make: commands (e.g., make:crud, make:repository, make:service).
    • Templates: Inspect the package’s templates for customization hooks.

Implementation Patterns

Usage Patterns

  1. CRUD Generation with Layers Generate a full repository-service-controller stack in one command:

    php artisan make:crud User --repository --service --api
    
    • --repository: Creates a repository interface/class (e.g., UserRepository).
    • --service: Adds a service layer (e.g., UserService).
    • --api: Generates an API resource (e.g., UserResource).
  2. Custom Makers Extend existing makers by overriding templates. For example, to modify the crud template:

    • Copy the template from vendor/c33s/maker-extra-bundle/src/Resources/skeleton/crud to resources/skeleton/crud.
    • Customize the files (e.g., add Laravel-specific logic like use Illuminate\Support\Facades\Auth;).
  3. Integration with Laravel

    • Service Providers: Register custom bindings for generated services in AppServiceProvider:
      $this->app->bind(UserService::class, function ($app) {
          return new UserService(new UserRepository());
      });
      
    • API Resources: Use the generated resources in routes:
      Route::apiResource('users', UserController::class)->except(['create', 'store']);
      
  4. Workflows

    • Team Onboarding: Use make:crud to scaffold boilerplate for new developers.
    • Rapid Prototyping: Quickly spin up API endpoints or admin panels with --api or --web flags.
    • Testing: Generate test stubs with make:test (if available) or mock services for unit tests.

Integration Tips

  • Laravel Mix/Vite: If generating frontend-related makers, ensure your build tools are configured to handle the new assets.
  • Database Migrations: Pair make:crud with make:migration for a complete feature setup:
    php artisan make:migration create_posts_table
    php artisan make:crud Post
    
  • Validation: Extend generated controllers to include custom validation rules in validate* methods.

Gotchas and Tips

Pitfalls

  1. Template Overrides

    • Issue: Custom templates in resources/skeleton may not reflect updates from package versions.
    • Fix: Use composer update c33s/maker-extra-bundle and re-apply customizations.
  2. Namespace Conflicts

    • Issue: Generated classes may conflict with existing namespaces (e.g., App\Services vs. App\Repositories).
    • Fix: Use the --namespace flag or manually adjust the template’s {{ namespacedClass }} placeholders.
  3. Laravel-Specific Quirks

    • Issue: Some templates assume Symfony conventions (e.g., EntityManager). Laravel uses Eloquent or repositories.
    • Fix: Override templates to replace EntityManager with Model::query() or repository calls.
  4. Command Caching

    • Issue: Changes to templates may not reflect immediately due to cached commands.
    • Fix: Clear Laravel’s command cache:
      php artisan cache:clear
      

Debugging

  • Verbose Output: Use --verbose with makers to debug template rendering:
    php artisan make:crud Post --verbose
    
  • Dry Runs: Check generated files before committing by running the command and inspecting the output directory.
  • Logs: Enable Laravel’s debug mode (APP_DEBUG=true in .env) to catch template errors.

Tips

  1. Partial Generation Use --only to generate specific parts of a CRUD stack:

    php artisan make:crud Post --only="controller,repository"
    
  2. Field Customization Pass --fields to define custom fields for the CRUD maker:

    php artisan make:crud Post --fields="title:string,content:text,published:boolean"
    
  3. API Resource Extensions Extend generated resources to add custom logic:

    namespace App\Http\Resources;
    
    use Illuminate\Http\Resources\Json\JsonResource;
    
    class PostResource extends JsonResource
    {
        public function toArray($request)
        {
            return [
                'id' => $this->id,
                'title' => $this->title,
                'custom_field' => $this->whenLoaded('customField'),
            ];
        }
    }
    
  4. Laravel Mix Integration For makers generating frontend assets (e.g., make:component), ensure your webpack.mix.js includes the new files:

    mix.js('resources/js/components/NewComponent.js', 'public/js')
       .postCss('resources/css/app.css', 'public/css', []);
    
  5. Testing Generated Code Write feature tests for generated controllers to ensure consistency:

    public function test_crud_operations()
    {
        $response = $this->get('/api/posts');
        $response->assertStatus(200);
    }
    
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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel