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

Rad Bundle Laravel Package

atompulse/rad-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle to your Laravel project via Composer:

    composer require atompulse/rad-bundle
    

    Register the bundle in config/app.php under providers (if using Laravel 5.5+ with auto-discovery, this may not be required).

  2. First Use Case: Rapid CRUD Generation The bundle is designed for RAD (Rapid Application Development). Start by generating a scaffold:

    php artisan rad:generate:crud User
    

    This creates a full CRUD interface for the User model (ensure the model exists first).

  3. Key Directories

    • Generated Code: Outputs to app/Rad/ by default (configurable in config/rad.php).
    • Configuration: config/rad.php (check for default values and override as needed).
    • Commands: php artisan rad: for all available generators.

Implementation Patterns

1. Model-Driven Development

  • Automatic CRUD: Generate controllers, views, and routes for any Eloquent model:
    php artisan rad:generate:crud Post --fields="title,body,published_at"
    
  • Custom Fields: Use --fields to specify which model attributes to include. Omit to auto-detect.
  • Relationships: Supports nested forms for belongsTo/morphTo/manyToMany:
    php artisan rad:generate:crud Comment --relationships="post:Post"
    

2. View Generation

  • Blade Templates: Outputs reusable Blade components (e.g., index.blade.php, edit.blade.php).
  • Custom Layouts: Override default layouts by publishing assets:
    php artisan vendor:publish --tag=rad-layouts
    
  • Partial Templates: Extend generated views by placing custom templates in resources/views/rad/.

3. API Integration

  • API Resources: Generate API-specific controllers/views:
    php artisan rad:generate:api User
    
  • Route Prefixes: Use --api flag to auto-prefix routes with /api/v1.

4. Workflow Integration

  • Seeding: Generate factory/seeder stubs:
    php artisan rad:generate:seeder User
    
  • Testing: Scaffold PHPUnit tests alongside controllers:
    php artisan rad:generate:test UserController
    
  • Event Listeners: Add event listeners via --events flag:
    php artisan rad:generate:crud Product --events="created,updated"
    

5. Configuration Overrides

  • Global Settings: Modify config/rad.php for:
    • Default namespace (rad_namespace).
    • View paths (view_paths).
    • Form field types (form_field_types).
  • Per-Generation: Override defaults via CLI flags (e.g., --namespace=Admin).

Gotchas and Tips

Pitfalls

  1. Namespace Conflicts

    • Generated code uses App\Rad by default. If this conflicts with existing code, override the namespace in config/rad.php or via CLI:
      php artisan rad:generate:crud User --namespace=Admin
      
    • Fix: Check config/rad.php for rad_namespace and adjust.
  2. Missing Dependencies

    • The bundle requires friendsofsymfony/jsrouting-bundle@2.0.*@dev. If missing, install it manually:
      composer require friendsofsymfony/jsrouting-bundle:2.0.*@dev
      
    • Fix: Ensure JsRoutingBundle is registered in AppKernel.php (Symfony) or config/bundles.php (Laravel <5.5).
  3. Symfony Version Mismatch

    • The package supports Symfony 3/4 but may clash with Laravel’s HTTP stack. If routes fail:
      • Fix: Clear cached routes:
        php artisan route:clear
        
      • Ensure Symfony\Bridge\Laravel\HttpKernel is loaded.
  4. Overwriting Existing Files

    • Generators skip existing files by default. To force overwrite:
      php artisan rad:generate:crud User --force
      
    • Tip: Use --dry-run to preview changes:
      php artisan rad:generate:crud User --dry-run
      

Debugging

  1. Generator Logs
    • Enable verbose output for debugging:
      php artisan rad:generate:crud User -vvv
      
  2. Template Issues
    • If Blade templates render incorrectly, check:
      • Published layouts (resources/views/layouts/rad/).
      • Custom partials in resources/views/rad/.
    • Fix: Clear Laravel’s view cache:
      php artisan view:clear
      

Extension Points

  1. Custom Field Types

    • Extend form field types by adding to config/rad.php under form_field_types:
      'custom_field' => \App\Rad\FieldTypes\CustomFieldType::class,
      
    • Implement Rad\FieldTypeInterface.
  2. Hooks and Events

    • Listen for rad.generated events to post-process generated code:
      // In a service provider
      event(new RadGenerated($model, $paths));
      
    • Tip: Useful for adding custom logic (e.g., injecting services into controllers).
  3. Route Customization

    • Override generated routes by publishing the router:
      php artisan vendor:publish --tag=rad-routes
      
    • Edit routes/rad.php to modify route definitions.
  4. Localization

    • Translations are stored in resources/lang/rad/. Extend by adding new language files or overriding existing ones.

Performance Tips

  1. Avoid Regenerating
    • Use --only to regenerate specific parts (e.g., views):
      php artisan rad:generate:crud User --only=views
      
  2. Exclude Fields
    • Skip sensitive fields (e.g., password) with --exclude-fields:
      php artisan rad:generate:crud User --exclude-fields="password,api_token"
      
  3. Batch Processing
    • For large projects, generate multiple CRUDs in sequence and commit incrementally.

Laravel-Specific Quirks

  1. Service Container Binding
    • If generated controllers fail to resolve dependencies, bind them manually:
      $this->app->bind(
          \App\Rad\Controllers\UserController::class,
          \App\Rad\Controllers\UserController::class
      );
      
  2. Route Model Binding
    • Ensure your models use Laravel’s implicit binding:
      public function getRouteKeyName()
      {
          return 'slug'; // or custom key
      }
      
  3. Middleware
    • Add middleware to generated controllers via --middleware:
      php artisan rad:generate:crud Post --middleware="auth,verified"
      
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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views