Hey guys, I use sage often and I constantly find myself adding in a routes file, so that I can use Vue to send my contact forms to the server to be emailed out. I was wondering if I made a pull request to the main repo with my additions that it would be considered?
I don’t mind doing that for sage - I just don’t want to waste my time if it doesn’t fit into the goal of sage.
Here are the files that would change in summary:
functions.php - add routes to the array map [‘helpers’, ‘setup’, ‘filters’, ‘admin’, ‘routes’]
add new routes.php inside the app folder with some boilerplate like:
<?php
namespace App;
// Define Routes
add_action( 'rest_api_init', function () {
register_rest_route( 'sage', '/submit-contact', array(
'methods' => 'POST',
'callback' => array( 'App\Controllers\Mail', 'sendContactForm' )
));
});
Then in a new Mail controller just add a static method that has a simple mail function that accepts name, email, message and directs it to the site_admin email. I think it might help people understand quicker how they can create routes like laravel to do custom server side things. Contact forms are quite common and easy to do especially if this was partially laid out for sage users.
Thanks