Api service with slim 4

I found tutorial

Does slim support Action (all in one) , for example, all about user will be in one class.

Action
class User
– create user
– raed user
– update user
– delete user
?

Second question

How to create database transaction with two or more queries?

Hi @Mark

Does slim support Action (all in one) , for example, all about user will be in one class.

This will be supported in Slim 4.8. See here.

How to create database transaction with two or more queries?

Please add more details. What database abstraction layer are you using?

PDO provides the beginTransaction, commit and rollBack methods for handling transactions.

Can you add one example?

Mysql and Postgresql Pdo.
I need one example.

That’s why I added the 2 links. See above.

When will be slim 4.8 available for install over composer?

Do I need use your selective library?

I ask for example for transaction in slim.

When will be slim 4.8 available for install over composer?

I don’t know. Maybe @l0gicgate knows more?

Do I need use your selective library?

Not sure what library you mean. Please add more details to your question.

I ask for example for transaction in slim.

Slim is a micro-framework and has no built-in database / transaction component. So there is no Slim specific example. You can use PDO directly or any QueryBuilder or ORM.

@odan

Can you update your tutorial for slim 4.8, and example for all action in one controller?

About your book, will be updated with new features?

Thank you

Hi Mark

I don’t think so, because in my personal opinion Single Action Controllers are the way to go and I highly recommend that.

But this does not mean that you can use other types of controllers, handlers, etc :slight_smile:

1 Like

Thank you @odan

And what is the better?
Write app in modules, e.g. modul user in one subfolders with action, data, domain, repository or all classes puts in each folder.

User
– action
– data
News
– action
– data

Or

Action
– usercreate
– useurpdate
– userread
– newsread
Etc…

I have written a lot about this topic in my Blog and eBook.

You can find more information here:

1 Like