DEV Community

Cover image for Another framework, Arrrgggg!!!
Tumusiime Ezra Jnr
Tumusiime Ezra Jnr

Posted on

Another framework, Arrrgggg!!!

Another PHP framework? Arrrgggg!!! More like, why not?

Pionia framework has the answer for this. Pionia trims off the unnecessary concerns of developing apis and you stay focused on only your business logic.

It also somehow meets both configuration and conventions in the midway.

Imagine scenarios where an api is done with in 20 mins, well, in python and Ruby that's not an imagination, but in php it was, but not anymore.

Frameworks like laravel are really good for fullstack applications and they shine that way. But if you intend to only pull off an API that will be easy to integrate with your frontend, then Pionia is your answer.

Why so?

  • Single request format.
    The server won't have to keep switching protocols to watch your requests. Everything is POST and with the $data key in your actions, all your request data is there. You pick what you want, or mark required the data you need.

  • Single Response format whether on failure or success! Really? Is that even nice? You may ask!

Yes it is, this is how. We introduce the concept of returnCodes for Status Codes. We maintain the same Status code 200 OK for all the requests that hit the application server, and as you already know, when a request returns 200 OK, tools like axios give you access to the returned data, now in the returned data, you get to set your own returnCode, you can maintain the existing http codes but you're also open now to even define your custom ones.

Thus the frontend does not need to read errors from the catch block of your http, but in the same try block, everything is there!

Now, I don't know if it was only me, but reading errors in axios was not my favorite part, but now, with Pionia, it is because it's not any different!

  • As you see the first two points, they have a new advantage they introduce, the fact that both the request and response are the same throughout, then it means one endpoint is enough for an entire app! Now, this is not an innovation, it's just an implementation. We have already seen API Gateways and Graphql tending to this path, and how about a framework that has it as the default behaviour.

After implementing this, we didn't need routes and controllers in Pionia, but also a new concept of Switches was introduced. Switches read the service and action defined in the request and point the entire traffic directly to that service(php class) and action(class method).

This is great, it implies that in your app, your entire logic has reduced to just your services. So like that, we have achieved developer performance since you focus on only services not forgetting maintainability too! Your code is easy to inherit since even the new dev will only have to look at services.

Generics in Pionia are another concept to get you started in seconds. These, if well used, can even reduce your time to pull off an API from minutes to even seconds.

Battle-tested components. We also believe that if something is working well, then don't reinvent it. That's why Pionia at it's core stands on the shoulders of giants like symfony and Nette. Our code generators are powered by Nette, our tests are powered by phpunit, our logs are powered by Monolog, our request sanitisation mechanisms are powered by symfony. This implies that most of the components working in Pionia are battle-tested to work with complex projects without breaking a sweat😓

Pionia also does more than this, it gives us a new approach to look at RBAC in php which is inspired by the combination of spring boot and django bytheway. This includes use of authentication backends that will set the ContextUserObject. So, no matter what you want to use, you're totally free! As long as you set the context user object. The framework being fully restful also expects your authentication to be stateless or sessionless. So anything you have in mind should work with Pionia framework!

Middlewares are still here. That means you get perform great staff like request sanitisation, encryption and decryption using our Middlewares!!

On program performance in abit, Pionia removes the model layer! Whyyyyyy?? Another great thing gone!! Damn framework!!! You may say!

But Rest applications are meant to return json data. This can be an array or object. Php as php knows both datatypes and gives you various ways to interact with them. So, when you query your database and get back your results, they are in one of the above formats. This is the normal underlying PDO. However, when you have models, then you do something called model hydration. This is where the above arrays and objects are mapped to a certain class. With objects, this might not be a big problem, but with arrays of objects, this is really expensive!

So, Pionia also knows that you need to easily query your database well, so, it has a tool called Porm. Porm can help you query any database supported by PDO and return the results in the format that is ready for exposure as an API.

This also has another added advantage. It implies Porm can work with all your already existing databases. We believe backend developers should focus on that and database engineers should focus on that! And yet, with this QueryBuilder, backend engineers can query any database whether new or existing and to make it more fun, multiple databases at a time!!

This should be just words, head over to https://pionia.netlify.app and see for yourself.

We welcome all contributions, criticisms sponsorship as that's how we shall grow!!

Have fun 😁

Top comments (0)