Writing Komposers
Komposers are like Controllers, but highly specialized.

What are Komposers?

To put it simply, Komposers are highly specialized Controllers.

They are classes where you define Komponents along with some basic functionality such as route configurations, booting behavior, authorization or validation rules. And they will handle AJAX requests made by their Komponents according to their specialization.

There are 3 types of Komposers:

  • `Form`  komposers: They attach to a single Model and sync user input with the DB (and storage for File uploads, for example).
  • `Query` komposers: They handle a query, a collection of Models (or plain arrays), browsing cards, paginating, filtering, sorting. etc...
  • `Menu`  komposers: They define Navigation menus (Navbar, Sidebar, Footer), perform turbo-navigation and are shared across different pages.

Generating templates

Artisan commands

To generate Komposers, the easiest way is to call the artisan commands below from the root directory of your project with the class name as a parameter. These commands will create a template for the class in the `app/Http/Komposers` directory of your application.

Generating a Form

php artisan kompo:form PostForm

Generating a Query

php artisan kompo:query PostsQuery

Generating a Table

php artisan kompo:table PostsTable

Generating a Menu

php artisan kompo:menu Navbar

Nesting in subfolders

You may also target a subfolder. For example, I like to put Menus in their own folder:

php artisan kompo:menu Menus/Navbar
Kompo folder structure
The folder structure convention is NOT technically required, it is just the default one kompo uses. You may organize your komposers however you wish.

Next, start creating your own Komposer by looking the specific docs of each one.