Skip to content

v0.5.1 - modsx:make converts the whole name

Choose a tag to compare

@Synerdy Synerdy released this 30 Aug 23:55
· 15 commits to master since this release

modsx:make converted only half the name

The module was written in the generator's form and the rest of the name passed through untouched:

modsx:make config Blog/MailSettings   ->  modsx-blog-MailSettings
modsx:make view   Blog/PostList       ->  modsx-blog/PostList

Kebab-case and StudlyCase inside one identifier — neither a config key you would type nor one Laravel would generate. Migrations were converted; nothing else was.

The entry in modsx.generators now settles the whole name:

modsx:make view      Blog/PostList          ->  modsx-blog/post-list
modsx:make view      Blog/Admin/PostList    ->  modsx-blog/admin/post-list
modsx:make config    Blog/MailSettings      ->  modsx-blog-mail-settings
modsx:make migration Blog/CreatePostsTable  ->  modsx_blog_create_posts_table
modsx:make controller Blog/PostController   ->  ModsxBlog/PostController   (untouched)

A {Studly} entry leaves the rest of the name alone, a class name already being written the way its generator wants it. Migrations stop being a special case in the code — they are one of three patterns rather than the exception. Conversion runs segment by segment, because Str::kebab('Admin/PostList') is admin/-post-list: the separator reads as a word boundary.

A longer scaffold list, commented out

The published config now offers Livewire, services, form requests, middleware, factories, seeders, tests, resources/css/, resources/js/, and view directories — all commented. The defaults are unchanged and stay short on purpose: a directory nobody fills in is invisible to git and reported by modsx:doctor, so a generous default would only make work for --fix.

Views take the same shape as everything else, the module going inside the framework's directory:

resources/views/
├── components/modsx-blog/   ->  <x-modsx-blog.card>
├── layouts/modsx-blog/
├── partials/modsx-blog/
└── modsx-blog/

layouts/modsx-blog/, not modsx-blog/layouts/ — the module comes second everywhere else in this convention, exactly as in resources/css/modsx-blog/. A starter kit's own layouts/app.blade.php carries no prefix, so no module claims it, and the two sit side by side. Modules are found at any depth.

Documentation caught up with the code

  • Limitations still said Blog and BlogPost could not coexist and that modsx:doctor reported their prefix as a conflict. Both stopped being true in 0.5.0. What remains is that a migration matching two modules goes to the longer name.
  • Installation now reads composer require --dev synerdy/modsx. Outside an artisan command the package does nothing at all — the service provider returns immediately unless the application is running in the console — and nothing in an application ever calls into it. The one case for require is named too: running modsx:* where dev dependencies are absent.
  • The naming tables no longer show a single file where the convention wants a directory, and a new paragraph says why the two name forms exist at all: directories under app/ are PSR-4 namespace segments, and a PHP identifier cannot contain a hyphen.

Full detail in the CHANGELOG.