Download the PHP package bornfight/maboo-maker-bundle without Composer
On this page you can find all versions of the php package bornfight/maboo-maker-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bornfight/maboo-maker-bundle
More information about bornfight/maboo-maker-bundle
Files in bornfight/maboo-maker-bundle
Package maboo-maker-bundle
Short Description Boilerplate code generator for projects with layered architecture. Inspired by Maboo
License MIT
Informations about the package maboo-maker-bundle
Maboo Maker Bundle
Boilerplate code generator for projects with layered architecture
Installation
To install this package, use Composer:
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:
Usage
There are multiple commands available which can work independently, but whenever possible, you can make your life easier just by running:
List of currently supported sub-commands:
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.
Happy path
Generating a new entity with scalar types for fields
- Run
bin/console make:maboo-scaffold
- Follow the interactive wizard:
- Select all available options (this is the default so just press ↵ Return to confirm)
- Select an existing module or create a new one. Existing folders within project source directory (
src/
) are suggested, so you can use ⇥ Tab for autocompletion.
Example:Booking
- Type entity name (for now, existing entities are also suggested when you start typing, but updating is currently not supported).
Example:Hotel
This creates a class insrc/Shared/Infrastructure/Persistence/Doctrine/Entity
- All classes will have this entity name suggested, but you can overwrite any of those. If you would like to keep the defaults, just confirm it by pressing ↵ Return:
- Domain model name:
Hotel
This creates a class insrc/Booking/Domain/Model
- Entity mapper name:
HotelMapper
This creates a class insrc/Shared/Infrastructure/Persistence/Doctrine/Mapper
- Write model names:
CreateHotel
andUpdateHotel
This creates classes insrc/Booking/Domain/WriteModel
- Repository interface and class names:
HotelRepository
andDoctrineHotelRepository
This creates an interface insrc/Booking/Domain/Repository
and a class insrc/Booking/Infrastructure/Persistence/Repository
- Basic specification interface and class names:
IsExistingHotelSpecification
andDoctrineIsExistingHotelSpecification
This creates an interface insrc/Booking/Application/Specification
and a class insrc/Booking/Infrastructure/Specification
- Validator name:
HotelValidator
This creates a class insrc/Booking/Application/Validator
- Manager name:
HotelManager
This creates a class insrc/Booking/Application/Manager
- Resolver name:
HotelResolver
This creates a resolver class insrc/Booking/Infrastructure/GraphQL/Resolver
- Mutation name:
HotelMutation
This creates a mutation class insrc/Booking/Infrastructure/GraphQL/Mutation
- Fixtures name:
HotelFixures
This creates a fixtures class insrc/Booking/Infrastructure/Persistence/DataFixtures
- Domain model name:
- Add fields:
Example:name
(string, 255, non-nullable),isOpen
(boolean, non-nullable),address
(string, 255, non-nullable),longitude
(float, nullable),latitude
(float, nullable) - Press ↵ Return one more time.
- Generate and apply migrations (these are Doctrine commands and have nothing to do with the generator):
bin/console make:migration
bin/console doctrine:migration:migrate
- Add some meaningful data to the fixtures or just load dummy data pregenerated based on field types:
bin/console doctrine:fixtures:load
- Generate GraphQL schema:
- Run
bin/console make:maboo-gql-schema
- Select the module (
Booking
) and the entity you've just generated (Hotel
)
This updates existingQuery.types.yaml
andMutation.types.yaml
files in directory/config/graphql/types
.
This also creates GraphQL input, payload and type schema files insrc/Booking/Infrastructure/Resources/config/graphql/types
- Run
- 🚀 All done!
Now try running a query in your favourite GraphQL GUI:
You should get something like:
It works!
Try running a mutation (by default, you must have admin rights):
The response should contain the ID of the newly created hotel:
Motivation
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.