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

Easy Dev Laravel Package

anas/easy-dev

Interactive Laravel code generator for complete CRUD with repository/service patterns. Auto-detects model relationships and scaffolds policies, DTOs, observers, filters, enums, API resources, routes, and more, with dry-run mode and customizable stubs.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Installation

    composer require anas/easy-dev
    php artisan vendor:publish --provider="Anas\EasyDev\EasyDevServiceProvider" --tag=easy-dev-config
    php artisan migrate
    
  2. Configure the Package

    • Edit config/easy-dev.php to set up your database connection, UI preferences, and CRUD defaults.
    • Example:
      'database' => [
          'connection' => 'mysql',
          'table_prefix' => 'ed_',
      ],
      
  3. Generate a Model & CRUD

    php artisan easy-dev:make Model Post --fields="title:string,body:text,is_published:boolean"
    php artisan easy-dev:make Crud Post
    
    • This creates a Post model, migration, and a fully functional CRUD UI at /admin/posts.
  4. Access the Admin Panel

    • Visit /admin (or your configured route) to interact with the generated CRUD.

First Use Case: Quick CRUD for a Blog

  • Scenario: Need a blog with posts table (title, body, published status).
  • Steps:
    1. Run the commands above.
    2. Visit /admin/posts to add/edit/delete posts via a pre-built UI.
    3. Customize the UI later (see Implementation Patterns).

Implementation Patterns

1. Model & Migration Generation

  • Automate Boilerplate:

    php artisan easy-dev:make Model User --fields="name:string,email:string:unique,role:string"
    
    • Generates:
      • Model (app/Models/User.php).
      • Migration (database/migrations/..._create_users_table.php).
      • Factory (if using Laravel’s make:factory).
  • Custom Fields: Use Laravel’s field types (e.g., string, text, integer, date, json) or extend with custom logic via EasyDevServiceProvider.


2. CRUD Generation

  • Basic CRUD:

    php artisan easy-dev:make Crud Post
    
    • Creates:
      • Controller (app/Http/Controllers/Admin/PostController.php).
      • Routes (routes/admin.php).
      • Blade views (resources/views/admin/posts/).
  • Customize CRUD:

    • Fields: Override defaults in config/easy-dev.php under crud_fields.
    • Views: Extend Blade templates (e.g., resources/views/admin/layouts/app.blade.php).
    • Logic: Override controller methods (e.g., PostController::store()).
  • Relationships:

    php artisan easy-dev:make Crud Post --with=author:User
    
    • Auto-detects and renders relationship fields (e.g., dropdown for author_id).

3. Repository & Service Patterns

  • Generate Repository:

    php artisan easy-dev:make Repository Post
    
    • Creates app/Repositories/PostRepository.php with:
      • Basic CRUD methods.
      • Hooks for custom logic (e.g., findWithRelations()).
  • Generate Service:

    php artisan easy-dev:make Service Post
    
    • Creates app/Services/PostService.php to encapsulate business logic.
    • Inject the repository:
      public function __construct(PostRepository $repository) {
          $this->repository = $repository;
      }
      
  • Usage in Controller:

    public function store(Request $request) {
        return $this->postService->create($request->all());
    }
    

4. UI Customization

  • Override Default Views: Copy vendor/anas/easy-dev/resources/views/admin/ to resources/views/admin/ to customize templates.

  • Dynamic UI: Use EasyDev::crud()->setField() to modify fields on-the-fly:

    // In a controller or service
    EasyDev::crud('Post')->setField('is_published', 'hidden');
    
  • Themes: Configure config/easy-dev.php:

    'theme' => 'dark', // Options: 'light', 'dark', 'custom'
    

5. API Endpoints

  • Generate API CRUD:

    php artisan easy-dev:make Api Post
    
    • Creates API routes (routes/api.php) and controller with JSON responses.
  • Custom API Logic: Override PostApiController methods (e.g., index()) to modify responses.


6. Seeding & Testing

  • Seed Data: Use Laravel’s DatabaseSeeder with EasyDev::seed():

    public function run() {
        EasyDev::seed('Post', 10); // Creates 10 dummy posts
    }
    
  • Testing: Mock repositories/services in PHPUnit:

    $this->mock(PostRepository::class)->shouldReceive('findAll')->andReturn([]);
    

Gotchas and Tips

Pitfalls

  1. Namespace Conflicts:

    • If you have a model Post in App\Models, ensure the generated Post doesn’t clash. Use --namespace flag:
      php artisan easy-dev:make Model Post --namespace=Blog
      
  2. Migration Conflicts:

    • Running make:model after easy-dev:make Model may duplicate migrations. Stick to one method per model.
  3. Relationship Auto-Detection:

    • EasyDev detects relationships via foreign keys. If it fails, manually define in config/easy-dev.php:
      'relationships' => [
          'Post' => [
              'author' => ['model' => 'User', 'foreign_key' => 'user_id'],
          ],
      ],
      
  4. Caching Issues:

    • Clear views/cache after customizing templates:
      php artisan view:clear
      php artisan cache:clear
      
  5. Permission Denied:

    • Ensure middleware (e.g., auth) is configured in routes/admin.php. EasyDev doesn’t auto-apply middleware.

Debugging

  1. Log Queries: Enable Laravel’s query logging in .env:

    DB_LOG_QUERIES=true
    

    Check storage/logs/laravel.log.

  2. Check Generated Code: Inspect bootstrap/cache/ for compiled views or use:

    php artisan easy-dev:dump
    
  3. Console Output: Run commands with -v for verbose output:

    php artisan easy-dev:make Crud Post -v
    

Configuration Quirks

  1. Table Prefix: Set in config/easy-dev.php to avoid conflicts with existing tables:

    'database' => [
        'table_prefix' => 'ed_',
    ],
    
  2. Field Types:

    • Use Laravel’s native types (e.g., string, text).
    • For custom types (e.g., json), extend the package or use string with validation.
  3. Soft Deletes: Enable in config/easy-dev.php:

    'soft_deletes' => true,
    
    • Adds deleted_at column and filters queries automatically.

Extension Points

  1. Custom Commands: Extend the package by creating a new Artisan command that uses EasyDev facade:

    use Anas\EasyDev\Facades\EasyDev;
    
    public function handle() {
        $crud = EasyDev::crud('Post');
        $crud->addField('custom_field', 'string');
    }
    
  2. Service Providers: Bind custom repositories/services:

    $this->app->bind(
        CustomPostRepository::class,
        function ($app) {
            return new CustomPostRepository(new PostRepository());
        }
    );
    
  3. Events: Listen to EasyDev events (e.g., CrudGenerated):

    Event::listen(CrudGenerated::class, function ($event) {
        // Post-process the generated CRUD
    });
    
  4. API Resources: Override API responses by extending EasyDev\Api\Resources\BaseResource:

    namespace App\Api\Resources;
    
    use EasyDev\Api\Resources\BaseResource;
    
    class PostResource extends BaseResource {
        public function toArray($request) {
            return [
                'id' => $this->id,
                'title' => strtoupper($this->title), // Customize
            ];
        }
    }
    

Pro Tips

  1. Bulk Operations: Use the built-in bulk actions in CRUD (e.g., delete multiple records) without writing code.

  2. Multi-Tenant Support: Extend the PostRepository to add tenant logic:

    public function findAll() {
        return $this->model::where('tenant_id', auth()->id())->
    
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle