I'm currently developing on a professional basis in PHP, noteably cakephp. I haven't spend much time in in the realm of procedural php, hence why I'm here
I have a college project with an Arduino board, where I need to interact via web browser with the on board API, and have a simple button interface driving it. I intend to install a simple project on the webserver and make two calls to the api.
My scenario is this: Post form form either button, Controller evaluates the button press, creates a GET request for the API, and redirects to a certain page. I can easily do this in cake, but I don't see the need to install a chunky framework for such a tiny, single page single controller application.
Is there a lightweight solution available to accommodate this, or would I be better off with just a single php page making the requests via ajax and updating the page content with jquery or something like that
If you want to use a framework (maybe you see this increasing in size over the next few years) then look at something like Silex
It is pretty simple to pick up and basically allows simple routing and allows for a simple REST API to be setup.
Otherwise you can just handle this with a single PHP files:
<script>
$(document).ready(function() {
//jquery here if you want to do it async
$(form).submit(function(e) {
$.post('/location/of/script.php, serialize(form), function(data) {
//do stuff with data
}
}
});
</script>
<!-- HTML CODE GOES HERE -->
HTML code for form & button:
<form method="POST">
<input type="submit" value="Submit">
</form>