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

Laravel Make View Laravel Package

lanciweb/laravel-make-view

Laravel package adding an artisan make:view command to generate Blade view files. Create single views using dot notation (auto-creates nested folders) or scaffold conventional CRUD resource views (index, show, create, edit) with --crud/-c.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require lanciweb/laravel-make-view
    

    Publish the config (if needed) with:

    php artisan vendor:publish --provider="Lanciweb\MakeView\MakeViewServiceProvider"
    
  2. First Use Case: Generate a single view for a home page:

    php artisan make:view home
    

    This creates resources/views/home.blade.php.

  3. Where to Look First:

    • Check the config/makeview.php for customization options (e.g., default view path, stubs).
    • Review the stubs/ directory in the package (if published) to understand template structure.

Implementation Patterns

Usage Patterns

  1. Nested View Generation: Use dot notation to create nested directories:

    php artisan make:view admin.dashboard.analytics
    

    Creates resources/views/admin/dashboard/analytics.blade.php.

  2. CRUD Workflow: For resource controllers, use the --crud flag to generate all standard views:

    php artisan make:view posts --crud
    

    Outputs:

    resources/views/posts/
      ├── index.blade.php
      ├── show.blade.php
      ├── create.blade.php
      └── edit.blade.php
    
  3. Custom Stubs:

    • Publish the package’s stubs to resources/stubs/:
      php artisan vendor:publish --tag=makeview-stubs
      
    • Override stubs (e.g., resources/stubs/views/blank.blade.stub) to modify generated templates.
  4. Integration with Controller Generation: Combine with make:controller for a full CRUD setup:

    php artisan make:controller PostController --resource
    php artisan make:view posts --crud
    
  5. Dynamic View Paths: Use the --path option to specify a custom directory:

    php artisan make:view admin.posts --crud --path=resources/views/custom
    

Workflows

  • Rapid Prototyping: Generate views alongside controllers to scaffold features quickly. Example:

    php artisan make:controller UserController --resource
    php artisan make:view users --crud
    
  • Component-Based Views: Generate partials (e.g., _header.blade.php) by omitting the --crud flag and using underscores in the name:

    php artisan make:view _partials.header
    
  • Team Onboarding: Standardize view structure by configuring default stubs (e.g., add @extends('layouts.app') to all views).


Gotchas and Tips

Pitfalls

  1. Stub Overrides:

    • If stubs are published but not customized, generated views may include unintended placeholders (e.g., {{ $slot }}).
    • Fix: Clear or modify stubs in resources/stubs/views/.
  2. Directory Permissions:

    • The command may fail if resources/views/ lacks write permissions.
    • Fix: Run chmod -R 755 resources/views/ or use --path to a writable directory.
  3. CRUD Naming Conflicts:

    • Generating --crud for a route that already has views (e.g., posts) will overwrite existing files.
    • Fix: Backup views or use --force cautiously.
  4. Dot Notation Edge Cases:

    • Trailing dots (e.g., admin..posts) or invalid characters (e.g., admin/posts) may cause errors.
    • Fix: Validate input or sanitize in a custom command class.
  5. Config Overrides:

    • The view_path in config/makeview.php defaults to resources/views/. Changing this affects all future generations.
    • Tip: Test changes in a fresh project to avoid unintended side effects.

Debugging

  • Verbose Output: Use --verbose to see the exact path being generated:

    php artisan make:view admin.posts --crud -v
    
  • Stub Debugging: Add {{ dd('Stub loaded') }} to stubs to verify they’re being used.

  • Command Customization: Extend the command by publishing the service provider and overriding methods in app/Providers/MakeViewServiceProvider.php.

Tips

  1. Aliases: Add a custom alias to your .bashrc or aliases file:

    alias mv='php artisan make:view'
    

    Usage:

    mv admin.dashboard --crud
    
  2. Partial Generation: Use @include directives in stubs to auto-generate common partials (e.g., _form.blade.php).

  3. Testing: Mock the command in PHPUnit tests:

    $this->artisan('make:view test.view')
         ->expectsOutput('resources/views/test/view.blade.php')
         ->assertExitCode(0);
    
  4. IDE Integration: Configure your IDE (e.g., PHPStorm) to recognize generated Blade files by adding resources/views/**/*.blade.php to "Files to Watch."

  5. Custom Templates: Create a resources/stubs/views/custom.blade.stub and reference it via --stub=custom:

    php artisan make:view home --stub=custom
    
  6. Environment-Specific Views: Use the --path option to generate environment-specific views (e.g., resources/views/staging/).

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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
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