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.
Installation
composer require anas/easy-dev
php artisan vendor:publish --provider="Anas\EasyDev\EasyDevServiceProvider" --tag=easy-dev-config
php artisan migrate
Configure the Package
config/easy-dev.php to set up your database connection, UI preferences, and CRUD defaults.'database' => [
'connection' => 'mysql',
'table_prefix' => 'ed_',
],
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
Post model, migration, and a fully functional CRUD UI at /admin/posts.Access the Admin Panel
/admin (or your configured route) to interact with the generated CRUD.posts table (title, body, published status)./admin/posts to add/edit/delete posts via a pre-built UI.Automate Boilerplate:
php artisan easy-dev:make Model User --fields="name:string,email:string:unique,role:string"
app/Models/User.php).database/migrations/..._create_users_table.php).make:factory).Custom Fields:
Use Laravel’s field types (e.g., string, text, integer, date, json) or extend with custom logic via EasyDevServiceProvider.
Basic CRUD:
php artisan easy-dev:make Crud Post
app/Http/Controllers/Admin/PostController.php).routes/admin.php).resources/views/admin/posts/).Customize CRUD:
config/easy-dev.php under crud_fields.resources/views/admin/layouts/app.blade.php).PostController::store()).Relationships:
php artisan easy-dev:make Crud Post --with=author:User
author_id).Generate Repository:
php artisan easy-dev:make Repository Post
app/Repositories/PostRepository.php with:
findWithRelations()).Generate Service:
php artisan easy-dev:make Service Post
app/Services/PostService.php to encapsulate business logic.public function __construct(PostRepository $repository) {
$this->repository = $repository;
}
Usage in Controller:
public function store(Request $request) {
return $this->postService->create($request->all());
}
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'
Generate API CRUD:
php artisan easy-dev:make Api Post
routes/api.php) and controller with JSON responses.Custom API Logic:
Override PostApiController methods (e.g., index()) to modify responses.
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([]);
Namespace Conflicts:
Post in App\Models, ensure the generated Post doesn’t clash. Use --namespace flag:
php artisan easy-dev:make Model Post --namespace=Blog
Migration Conflicts:
make:model after easy-dev:make Model may duplicate migrations. Stick to one method per model.Relationship Auto-Detection:
config/easy-dev.php:
'relationships' => [
'Post' => [
'author' => ['model' => 'User', 'foreign_key' => 'user_id'],
],
],
Caching Issues:
php artisan view:clear
php artisan cache:clear
Permission Denied:
auth) is configured in routes/admin.php. EasyDev doesn’t auto-apply middleware.Log Queries:
Enable Laravel’s query logging in .env:
DB_LOG_QUERIES=true
Check storage/logs/laravel.log.
Check Generated Code:
Inspect bootstrap/cache/ for compiled views or use:
php artisan easy-dev:dump
Console Output:
Run commands with -v for verbose output:
php artisan easy-dev:make Crud Post -v
Table Prefix:
Set in config/easy-dev.php to avoid conflicts with existing tables:
'database' => [
'table_prefix' => 'ed_',
],
Field Types:
string, text).json), extend the package or use string with validation.Soft Deletes:
Enable in config/easy-dev.php:
'soft_deletes' => true,
deleted_at column and filters queries automatically.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');
}
Service Providers: Bind custom repositories/services:
$this->app->bind(
CustomPostRepository::class,
function ($app) {
return new CustomPostRepository(new PostRepository());
}
);
Events:
Listen to EasyDev events (e.g., CrudGenerated):
Event::listen(CrudGenerated::class, function ($event) {
// Post-process the generated CRUD
});
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
];
}
}
Bulk Operations: Use the built-in bulk actions in CRUD (e.g., delete multiple records) without writing code.
Multi-Tenant Support:
Extend the PostRepository to add tenant logic:
public function findAll() {
return $this->model::where('tenant_id', auth()->id())->
How can I help you explore Laravel packages today?