bornfight/maboo-maker-bundle
Symfony bundle that generates boilerplate for layered architectures. Provides interactive scaffolding plus makers for modules, Doctrine entities/domain models, write models, mappers, repositories, validators, managers, resolvers, mutations, fixtures, and GraphQL schema/types.
Boilerplate code generator for projects with layered architecture
To install this package, use Composer:
composer require bornfight/maboo-maker-bundle --dev
If you are using Symfony Flex, this will install and enable the Maboo Maker bundle automatically.
If not, you should add this manually to your config/bundles.php file:
return [
// ...
Bornfight\MabooMakerBundle\BornfightMabooMakerBundle::class => ['dev' => true, 'test' => true],
];
There are multiple commands available which can work independently, but whenever possible, you can make your life easier just by running:
bin/console make:maboo-scaffold
List of currently supported sub-commands:
make:maboo-module # Creates a bounded context (module) folder (if it does not exist yet)
make:maboo-entity # Creates or updates a Doctrine entity class
make:maboo-domain-model # Creates or updates a domain model class
make:maboo-write-models # Creates or updates write models for a model class
make:maboo-entity-mapper # Creates or updates mapper for a model class
make:maboo-repository # Creates or updates a repository interface and concrete implementation
make:maboo-validator # Creates or updates a validator and specification
make:maboo-manager # Creates or updates a resource manager
make:maboo-resolver # Creates or updates a resolver
make:maboo-mutation # Creates or updates a mutation class
make:maboo-fixtures # Creates or updates a fixtures class with some dummy data
make:maboo-gql-schema # Creates or updates GraphQL types and schema
make:maboo-scaffold will start the interactive wizard and ask you which of the components you need and then internally execute all selected commands one by one.
bin/console make:maboo-scaffoldsrc/) are suggested, so you can use ⇥ Tab for autocompletion.BookingHotelsrc/Shared/Infrastructure/Persistence/Doctrine/EntityHotelsrc/Booking/Domain/ModelHotelMappersrc/Shared/Infrastructure/Persistence/Doctrine/MapperCreateHotel and UpdateHotelsrc/Booking/Domain/WriteModelHotelRepository and DoctrineHotelRepositorysrc/Booking/Domain/Repository and a class in src/Booking/Infrastructure/Persistence/RepositoryIsExistingHotelSpecification and DoctrineIsExistingHotelSpecificationsrc/Booking/Application/Specification and a class in src/Booking/Infrastructure/SpecificationHotelValidatorsrc/Booking/Application/ValidatorHotelManagersrc/Booking/Application/ManagerHotelResolversrc/Booking/Infrastructure/GraphQL/ResolverHotelMutationsrc/Booking/Infrastructure/GraphQL/MutationHotelFixuressrc/Booking/Infrastructure/Persistence/DataFixturesname (string, 255, non-nullable), isOpen (boolean, non-nullable), address (string, 255, non-nullable), longitude (float, nullable), latitude (float, nullable)bin/console make:migrationbin/console doctrine:migration:migratebin/console doctrine:fixtures:loadbin/console make:maboo-gql-schemaBooking) and the entity you've just generated (Hotel)Query.types.yaml and Mutation.types.yaml files in directory /config/graphql/types.src/Booking/Infrastructure/Resources/config/graphql/typesNow try running a query in your favourite GraphQL GUI:
query {
hotels {
id
name
isOpen
address
longitude
latitude
}
}
You should get something like:
{
"data": {
"hotels": [
{
"id": "a89b8a17-3b15-4a23-9ad0-67229f13fc18",
"name": "example",
"isOpen": true,
"address": "example",
"longitude": 20.5,
"latitude": 20.5
}
]
}
}
It works!
Try running a mutation (by default, you must have admin rights):
mutation {
createHotel(input: {
name: "Westin"
isOpen: false
address: "Izidora Kršnjavoga 1, 10000 Zagreb"
longitude: 45.80689045084249
latitude: 15.9662605177903
}) {
hotel {
id
}
}
}
The response should contain the ID of the newly created hotel:
{
"data": {
"createHotel": {
"hotel": {
"id": "061a7975-4334-4d00-9a00-4243ac4a9726"
}
}
}
}
This bundle should make creating a bunch of files with a bunch of boilerplate code a cinch.
Copy-pasting existing entities and models and then renaming just some fields can be cumbersome and error-prone task. It is also time-consuming task and makes you feel like a code monkey.
We use some strict rules and instead of looking for analogies in existing classes and lots of manual work, this generator does that for you.
The very implementation was heavily influenced by Symfony's Maker Bundle. Some parts of the code in it are literally a copy-paste because mentioned bundle has classes declared as final which makes it impossible to extend them and overwrite just some parts of the logic.
How can I help you explore Laravel packages today?