Quick Start
To better exemplify the benefits of using FastEndpoints we are going to build an API for manipulating blog posts.
This API will be able to:
- Create
- Retrieve
- Update and
- Delete a blog post
Full source code can be found at matapatos/wp-fastendpoints-my-plugin Β»
Plugin code structure π¨
To hold this API we are going to create a plugin called MyPLugin - don't forget that logic shouldn't be contained in a theme - with the following structure:
my-plugin
β my-plugin.php # Registers the plugin provider
β composer.json
β
ββββsrc
β β constants.php
β β
β ββββApi
β β β
β β ββββRouters
β β β β Posts.php # Holds our custom endpoints
β β β
β β ββββSchemas
β β β
β β ββββPosts
β β β CreateOrUpdate.json # Validates request payload
β β β Get.json # Validates responses and discards unwanted fields
β β
β β
β ββββProviders
β β ApiServiceProvider.php # Registers all routers
β β MyPluginProvider.php # Bootstraps our plugin
β β ProviderContract.php
β
ββββtests