maker-bundle
maker-bundle copied to clipboard
[RFC][WIP] add scaffolding system (`make:scaffold`)
This adds a make:scaffold ...<scaffold> command. This is an alternative to what I'm calling single-use makers like make:register/make:user. We could potentially deprecate these other makers.
A scaffold consists of:
- files that are copied to your project to create the feature (including tests that are immediately runnable and pass!)
- required Composer packages (these are auto-installed)
- required JS packages (these are auto-installed)
- dependent scaffolds (most current scaffolds depend on others, ie
registerrequiresauth) - A little configuration system to allow more advanced file manipulations (ie update an exiting yaml file)
Some additional notes about this feature:
- Scaffolds are grouped by Symfony major versions with 6.0 being the only supplied version currently.
- These are meant to be run on new projects. Running them on an established project is possible but since the supplied files override existing files, you'll have to be careful and use git to help with conflicts.
- Copying files from a scaffold is currently "dumb" and they just replace existing files without confirming. It could be possible to make this smarter.
- Scaffolds could be grouped into "starter-kits" like what's provided with Laravel Breeze/Jetstream.
- I don't really want a wizard for these scaffolds. I think these add a huge amount of complexity. If we want a variation on a scaffold, we'd create a new scaffold.
- A future iteration could provide styling options? tailwind/bootstrap versions of each scaffold
- The generated code (especially the tests) is opinionated and use several of my personal libraries (zenstruck/browser|foundry). This is really "How Kevin Writes Symfony Apps" :). I don't have an issue if we want to make changes to code/tests to make them "more generic".
bin/console make:scaffold(no arguments) lists the available scaffolds to choose from.bin/console make:scaffold x y zinstalls scaffoldsx,yandz.
This PR provides the following scaffolds:
homepage: basic homepage controller, template, functional test for other scaffolds to useuser: user entity/repository, foundry factory and unit testauth: form login with functional testsregister: registration form with functional testschange-password: change password form with functional testsprofile: user profile management form with functional testsreset-password: using symfonycasts/password-reset-bundlebootstrapcss: installs/configures bootstrap with encore
Included is also a starter-kit. This is just another scaffold but it includes all the above scaffolds (styled with bootstrap) and an application shell. The shell has the following features:
- navbar on every page with:
- login & register links if not logged in
- manage profile, change password & logout user menu
- forgot password link on login page
Future ideas for scaffolds:
reset-password:stateless: using signed urls instead of db token tableregister:verification: similar to register but with email verificationchange-email: change email system for verified emailstailwindcss: similar to the current bootstrapcss scaffold but for Tailwind CSS
Future ideas for starter-kits:
starter-kit:verifcation: similar to the current starter kit but with email verificationstarter-kit:tailwind: similar to the current starter kit but for Tailwind CSSstarter-kit:verification:tailwind: combination of the above two starter kits
Test this PR:
symfony new project
cd project
composer config repositories.maker vcs [email protected]:kbond/maker-bundle
composer require symfony/maker-bundle:dev-scaffolding
composer require process # required for this maker
composer require log # (optional) to surpress logs in console
bin/console make:scaffold starter-kit
# run unit tests
DATABASE_URL="sqlite:///%kernel.project_dir%/var/test.db" bin/phpunit
# test in browser!
echo DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" > .env.local
symfony server:start -d
Some TODOS:
- [x] add better descriptions/help for each scaffold, post install notes ("what's next")
- [x] deprecate some existing maker's that are replaced by scaffolds
- [x] smarter overwrites: if contents is the same, skip, if contents are different, ask user to confirm.
- [x] ~Adjust password-reset to flash the "email sent" message instead of a separate template.~ Decided to leave the email sent template as there is more detail than we'd probably want in a flash message.
- [ ] base.html.twig patch with flashes...
- [x] cleanup configuration system, add some helper methods to
FileManager(iemodifyYaml,modifyJson,appendToFile,replaceInFile). - [x] suffix the scaffold files with
.tplto avoid your IDE from suggesting - [x] instead of using
Filesystem::mirror()to copy scaffold files, useFilesystemManager- this will allow the tests to lint the php/template files. - [x] replace require package "aliases" with real packages to improve perf
The following labels could not be found: plugins.
A newer version of bootstrap exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.
OK, I won't notify you again about this release, but will get in touch when a new version is available. If you'd rather skip all updates until the next major or minor version, let me know by commenting @dependabot ignore this major version or @dependabot ignore this minor version. You can also ignore all major, minor, or patch releases for a dependency by adding an ignore condition with the desired update_types to your config file.
If you change your mind, just re-open this PR and I'll resolve any conflicts on it.
reopening...
@dependabot recreate