Skip to content

Next-gen: javaabu/generators v2.0 #18

Open

Description

@n4ff4h

New major of the code generators: smarter generation (relations, pivot tables, filters, bulk actions), multi-auth, nested models, media, field selection, Blade and Inertia React output, translatable.

Package: javaabu/generators · Target: v2.0 (from v1.18) · Wave: 5
Depends on: javaabu/filters, javaabu/bulk-actions, javaabu/mediapicker, javaabu/permissions, javaabu/auth, javaabu/stencil
Optional: javaabu/translatable

Built to the next-gen general rules: CI with test and coverage badges, full docs for people and agents, Laravel Boost guideline and skill, Javaabu codestyle, PHP 8.4 / Laravel 12+ (Laravel packages) or TypeScript (JS packages), Dhivehi and RTL, Blade and Inertia React for views, overridable controllers and policies with javaabu/permissions.

Checklist

Developed by an agent orchestrated from the Javaabu next-gen plan. Cross-package requests go in the dependency's repo with the cross-package label.

Activity

  1. added
    next-genNext-gen Javaabu packages
    epicTracks a whole package
    on Nov 4, 2026
  2. n4ff4h commented on Nov 5, 2026

    @n4ff4h
    Author

    Implementation plan (package agent)

    All work is on the next-gen branch (from master); one PR into master at the end.

    Architecture

    v2 keeps the v1 shape (read a table's schema, build typed fields, render stubs through javaabu/generator-helpers). The generated code is rewritten for the next-gen packages, and the internals are reorganised around one resolved definition per resource:

    • Schema\SchemaInspector: driver-agnostic schema reading through Laravel's Schema::getColumns()/getForeignKeys()/getIndexes(). It supports MySQL/MariaDB, PostgreSQL and SQLite and replaces the MySQL-only resolver. Enum options come from the column type (MySQL) or from check constraints (PostgreSQL, SQLite). Enum classes come from an enum: comment or the generators.enums config map. doctrine/dbal is dropped.
    • Schema\RelationResolver: scans every table.
      • belongsTo: foreign keys on this table.
      • hasMany: foreign keys on other tables pointing at this table.
      • belongsToMany: pivot tables (two foreign keys and no other data columns, such as category_product). These are skipped as resources of their own.
    • ResourceDefinition: the table plus the developer's choices: index/form/show fields, the parent for nested resources, media collections, the view stack, the user type/guard and translatable fields. Every generator renders from it.
    • The generator package has no runtime dependency on the packages it generates code for. They go in suggest and require-dev (for the integration app). Runtime require is only illuminate, javaabu/generator-helpers and laravel/prompts.

    Generated code (per table, php artisan generate:all products --create)

    File Built on
    app/Models/Product.php Relations from the schema, casts, SoftDeletes, HasAttachments for media, JsonTranslatable when the table has translations/lang and translatable is installed
    database/factories/ProductFactory.php
    app/Policies/ProductPolicy.php extends Javaabu\Permissions\Policies\ResourcePolicy
    Permissions::resource('products', …) Added to AppServiceProvider::boot()
    app/Filters/ProductFilters.php javaabu/filters: text search over string columns, select for enums/belongsTo/belongsToMany, ternary for booleans, date and number ranges, trashed; sorts on sortable columns
    app/BulkActions/ProductBulkActions.php Delete / restore / force delete with can()
    app/Stencil/ProductForm.php javaabu/stencil fields, which also produce the validation rules, so there is no FormRequest any more
    app/Http/Controllers/Admin/ProductsController.php Resource controller plus restore/force delete; Blade or Inertia
    Routes In routes/admin.php: Route::resource(), Route::bulkActions()
    Blade views (resources/views/admin/products/*) <x-forms::…>, {{ $form }}, <x-filters::bar>, <x-bulk-actions::actions>
    Inertia React pages (resources/js/pages/admin/products/*.tsx) + ProductResource <StencilForm>, <FilterBar>, <BulkActionsTable>
    tests/Feature/Admin/ProductsControllerTest.php Self-contained feature tests using the configured admin user model/guard and permissions:sync
    app/Exports/ProductsExport.php Kept, on exports v2

    Commands and options

    • generate:all|model|factory|policy|permissions|filters|bulk-actions|form|controller|routes|views|test|export {table}
    • Options:
      • --columns
      • --index=name,price / --form=… / --show=…
      • --interactive (Laravel Prompts multiselects for the fields)
      • --views=blade|inertia
      • --parent=categories, for nested routes admin/categories/{category}/products with scoped bindings
      • --media=featured_image:image,gallery:image:multiple
      • --translatable[=fields]
      • --create, --force, --except
    • generate:auth {table} --type=customer [--migration] creates a user type on javaabu/auth v3. auth v3 ships the auth controllers and views, so the generator emits:
      • the model extending Javaabu\Auth\Models\User
      • optionally a migration using UserSchema::columns()
      • the config/auth.php guard, provider and broker
      • the javaabu-auth.user_types entry
      • Route::authRoutes() and Route::userAccountActions()
      • permissions and policy
      • the admin CRUD for the type
    • Removed in v2 (documented in docs/upgrading.md):
      • The v1 API controller/test generators and the per-type auth controller generators (auth v3 owns those).
      • FormRequests (stencil forms validate).
      • Everything that depended on javaabu/helpers.

    Testing

    1. Unit and feature tests for the inspector (SQLite, MySQL, PostgreSQL in CI), the field types and each generator's output (golden files).
    2. Integration (the real check): a CI job builds a Testbench app (workbench/ overlay on Testbench's skeleton) with every next-gen package installed. It migrates fixture tables, runs generate:all / generate:auth for Blade and Inertia, plain, nested, media and translatable cases, then runs the generated tests with PHPUnit. There is also a leg without javaabu/translatable.
    3. CI fails if javaabu/helpers or javaabu/settings ^1 appears in composer show --tree --no-dev.

    Order of work

    1. Foundations: PHP 8.4 / Laravel 12+, CI matrix, coverage and codestyle #6 foundations
    2. Schema inspector and relations (Smarter generators #7 base)
    3. Resource definition and field selection (Choose fields for index and forms #11)
    4. Generators rewritten for the next-gen packages with Blade (Smarter generators #7, Blade and Inertia React output #12)
    5. Integration harness
    6. Inertia (Blade and Inertia React output #12)
    7. Nested (Nested models #9)
    8. Media (Media #10)
    9. Multi-auth (Multi-auth generator #8)
    10. Translatable (Optional javaabu/translatable support #16)
    11. Dhivehi (Dhivehi localization and RTL #15)
    12. Docs (Documentation for people and agents #13) and Boost (Laravel Boost guideline and skill #14)

    Open questions (decided for now, recorded here)

    • Layouts: the packages ship no admin layout, so Blade views extend a configurable layout (generators.blade.layout, default layouts.admin, section content), and Inertia pages rely on the app's persistent layout.
    • Admin user and guard: configurable (generators.admin.user_model, generators.admin.guard); nothing assumes web or App\Models\User.
    • Dhivehi in generated code: resource-specific strings in generated code can't be translated automatically. The generator adds Dhivehi for the generic phrases it uses to the app's lang/dv.json and lists the rest for the developer.
  3. n4ff4h commented on Nov 5, 2026

    @n4ff4h
    Author

    Summary

    Every next-gen issue is closed except #17 (docs registration, needs-human). CI is green on next-gen. PR #19 into master is open for review and isn't merged.

    What was built

    • Schema reading. Tables are read through Laravel's schema builder on MySQL, MariaDB, PostgreSQL and SQLite. Enum options come from column types or check constraints, and enum classes from comments or generators.enums.
    • Relations. belongsTo, hasMany and belongsToMany (pivot tables) are found from the whole schema.
    • The generated code. For each table:
      • a model and factory
      • a javaabu/permissions ResourcePolicy and Permissions::resource()
      • javaabu/filters filters and sorts
      • javaabu/bulk-actions bulk actions
      • a javaabu/stencil form, which also validates
      • a controller and routes
      • Blade (javaabu/forms v2) or Inertia React (@javaabu/forms) pages
      • feature tests that pass as generated
      • Dhivehi for the generic phrases
    • Options.
      • --index, --form, --show and --interactive to choose fields
      • --parent for nested resources
      • --media for mediapicker attachments
      • --translatable (optional; detected)
      • generate:auth for javaabu/auth v3 user types, which also generates the admin pages of their users
    • Testing.
      • Unit, schema and snapshot tests.
      • An integration app (workbench/). CI generates a whole admin into it (every column type, a pivot, soft deletes, enum classes, Blade and Inertia, a nested resource, media, a translatable model, a user type) and runs its 111 generated tests.
      • Pint on the generated PHP, and typecheck and Prettier on the generated React pages.
      • The PHP 8.4/8.5 × Laravel 12/13 × lowest/stable matrix, schema legs on MySQL, MariaDB and PostgreSQL, and a leg without javaabu/translatable.
    • Docs. docs/ (including upgrading.md), llms.txt, the Boost guideline and skill, and AGENTS.md.

    Out of scope, on purpose

    • API generators (v1's generate:api*): they were built on javaabu/helpers and are removed.
    • FormRequests: the stencil form validates.
    • Per-controller auth generators: auth v3 ships the auth controllers and pages.
    • Sidebar menus and icons.
    • Exports: generate:export writes an exports v2 class but isn't part of generate:all, and isn't wired into the index page.
    • Parent authorization: nested controllers don't check the parent's policy. The docs show how to add it.

    For the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicTracks a whole packagenext-genNext-gen Javaabu packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions