Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Basic Demo Repository (CRUD), Symfony 6 #1

Open
tacman opened this issue Jun 19, 2022 · 8 comments
Open

feat: Basic Demo Repository (CRUD), Symfony 6 #1

tacman opened this issue Jun 19, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@tacman
Copy link

tacman commented Jun 19, 2022

It'd be great to see this bundle in action.

In particular, what I'd like to see is a trivial application like this

symfony new adr-demo --webapp && cd adr-demo
bin/console make:entity Blog 
   # title, string 
   # content, text
bin/console make:crud Blog
composer req pitch/symfony-adr

And then refactor the controller to use your bundle and ADR.

Also, the above doesn't work, because the bundle is locked to Symfony 5.

@tacman tacman added the enhancement New feature or request label Jun 19, 2022
@ph-fritsche
Copy link
Owner

Thanks for filing this issue.

I've made the library compatible with Symfony6:
Check out https://github.com/ph-fritsche/symfony-adr/releases/tag/v1.4.0

@tacman
Copy link
Author

tacman commented Jun 20, 2022 via email

@ph-fritsche
Copy link
Owner

Have a look at https://github.com/ph-fritsche/pitch-demo.
Does this showcase the concept for you? Would you help improving the documentation so that this library might be useful to others?

@tacman
Copy link
Author

tacman commented Jun 22, 2022

Yes, thanks, that's helpful, to see it in action. I'm still struggling a bit, but I'll re-read the article after diving into the code more.

I'll add a README there and submit a PR, and open an issue there as to some of the dependencies. In particular, the demo uses phf/collection, how essential is it to use that?

@tacman
Copy link
Author

tacman commented Jun 22, 2022

Have you considered creating some makers? e.g. bin/console make:adr? I'm not sure how it would work (because I'm still learning how, why and when to use ADR), but perhaps it would help toward re-recreating a demo.

But having the demo is definitely helping to see where things happen

@ph-fritsche
Copy link
Owner

phf/collection is just a utility to express someType[]. It is not necessary to use it at all, just a convenient method to express a List of typed elements.

pitch/symfony-adr provides the separation of Response and Action. Just like you define classes for entities that you store in the database, you should create entity classes for payload created at runtime, e.g. a paginated table page as response to a search endpoint. Then you add handlers to convert these entities into a response that is acceptable for the client. For a browser view this might be HTML and for a JS client library that might be JSON and for a spreadsheet export this might be XLSX.

pitch/form allows you to remove the reoccurring form handling from controllers and just deal with the submitted and valid form there. If you use it with pitch/symfony-adr, you can add handlers to convert the FormInterface for GET and invalid POST requests into responses that are acceptable for the client.

@ph-fritsche
Copy link
Owner

Have you considered creating some makers? e.g. bin/console make:adr? I'm not sure how it would work (because I'm still learning how, why and when to use ADR), but perhaps it would help toward re-recreating a demo.

I've written these packages to reduce repeated code and thus make it easier for me to circle back to projects months/years later to apply changes.

I've made these open-source so that others who might find it useful can collaborate on this. This is issue#1, so no idea how many users for a maker would be out there. ^^

@tacman
Copy link
Author

tacman commented Jun 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants