https://github.com/sroehrl/crud-transformer-video
MVC (or at least the idea) is still one of the most relevant patterns
Implementations reach from very strickt to very loose definitions. But some things are always true: You will write reusable models for every available entity type. This always leads to transactions with a persistent storage (aka database) and the old four letters C.R.U.D - Create Read Update Delete will make the majority of your work. And some things have to be custom, right? I mean, every project has its own ruleset of what happens when what kind of data gets updated, how to validate certain inputs, what to trigger on deletion. Well, what if your model was just that,
A ruleset that defines how CRUD works - and nothing else.
neoan3 has automated routing, why would it stop at models? The challenge with abstraction is always the same: how to simplify without taking away any freedom? Removing the index-model from the core, updating the autoloader and providing the transformer-app as well as enhancing the cli-tool did the trick.
All you need to to is to update your neoan3-cli and you are ready to go.
So, what is the typical application flow? In theory, nothing changed. You will likely receive requests via API endpoints you didn't have to write routing for, you will authorize the call and call the model to retrieve, update, delete or create entities and return a result. The only difference is, your complete code for a particular endpoint could look like this:
<?php
namespace Neoan3\Components;
use Neoan3\Apps\Stateless;
use Neoan3\Model\TaskModel;
class Task extends Demo
{
function getTask(array $body)
{
return $this->executeTransformer('find', $body);
}
function postTask(array $body)
{
return $this->executeTransformer('create', $body);
}
function updateTask(array $body)
{
return $this->executeTransformer('update', $body);
}
private function executeTransformer($function, $body)
{
Stateless::restrict();
return TaskModel::$function($body);
}
}
The good, the bad, the ugly
You will be pleased to hear that this time test-coverage was 100% before publishing a version. But documentation is still a huge problem and will require some additional time. We would be pleased to see volunteers jump at us, but I know you guys aren't sitting around bored at home either. As a start, this video should give you first insight into what the potential is and how this will further enhance your development speed.