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

Create a Rest Controller scaffold command. #57

Open
BE-Webdesign opened this issue Sep 22, 2017 · 8 comments
Open

Create a Rest Controller scaffold command. #57

BE-Webdesign opened this issue Sep 22, 2017 · 8 comments

Comments

@BE-Webdesign
Copy link

Hi Folks!

The scaffold commands are really invaluable, and I was wondering if wp-cli could feature a scaffolding command for creating REST API controllers. For the most part controllers are just massive boilerplate (which is good), and I think it would be great to have a wp-cli command to generate that boilerplate. It could by default output routes for EDITABLE, DELETABLE, CREATABLE, and READABLE. Then in one of the flags you could override that to only get what you need. I would be willing to help create these commands, but would first like to know more about the WP CLI process.

Thank you, wp-cli rocks!

@danielbachhuber
Copy link
Member

👍 I dig the idea.

@BE-Webdesign
Copy link
Author

👍 I dig the idea.

What are next steps?

@schlessera
Copy link
Member

schlessera commented Sep 22, 2017

@danielbachhuber We should decide whether this should go into the existing, bundled scaffold command (alongside CPTs, taxonomies, etc...), or whether this should be a separate command that you can optionally install.

Given that this is an integral part of WordPress Core and that it seems to get more and more important for normal WP development, I'd go with a PR against wp-cli/scaffold-command to include it as a bundled command.

@danielbachhuber
Copy link
Member

Given that this is an integral part of WordPress Core and that it seems to get more and more important for normal WP development, I'd go with a PR against wp-cli/scaffold-command to include it as a bundled command.

I agree with this.

@BE-Webdesign Can you share your proposed output for the routes?

@BE-Webdesign
Copy link
Author

Can you share your proposed output for the routes?

I would have to think a bit about it first. I can make a gist.

@BE-Webdesign
Copy link
Author

BE-Webdesign commented Sep 22, 2017

https://gist.github.com/BE-Webdesign/42df5e6117659b7bb8b5066ab4f1c90a

This would be a rough thing, I guess. It's not the full picture.

@danielbachhuber
Copy link
Member

Ideally, it'd be functional code. What do you think about scaffolding individual routes instead, with command arguments for each of the features that register_rest_route() supports?

@BE-Webdesign
Copy link
Author

BE-Webdesign commented Sep 22, 2017

Ideally, it'd be functional code. What do you think about scaffolding individual routes instead, with command arguments for each of the features that register_rest_route() supports?

That would probably be a better starting place, then we could create the controller scaffolding based on those outputs.

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

No branches or pull requests

3 participants