An example module which demonstrates on how to create custom API endpoints with the use of:
- Controller Annotations
- MediaMonks Rest API
- Fractal
- Symfony Form
- Symfony Validator
- Controllers as Services
- Service Autowiring
- PHP 7.2+
- Drupal 8.6+
Add the following repository to your composer.json file under repositories:
{
"type": "vcs",
"url": "https://github.com/slootjes/drupal-example-api-module"
}
and then add the module with composer:
composer require drupal/example-api
Then enable the module Controller Annotations and Example API module like you're used to and you're good to go.
This module is created for educational and research purposes. Most examples are not following Drupal security best practices and thus are not meant to be used as-is. I cannot be held responsible for any issues that occur from you using these examples.