Nette Model – The missing abstract model (New Extension)

2 months ago

farhanianz
Member | 8
+
0
-

Hello there,

I was using the framework for the past couple of days. The feelings are mixed. Sometimes I feel like I'm having all the needed feature just from one provider & which are perfectly combined together to form a full-stack framework. However, I really miss an ORM built-it for it. I also miss a cli in nette framework. Hopefully it will have those overtime.

As I already started one of my project with the framework, I needed some ways to find out how it's going to happen. There is enough possibilities with the framework but it doesn't have an huge active community right now, using English.

The lack of implementing models in proper way is what bothered me a lot. The repository pattern, factory pattern or just models, I'm confused to what I should do. Maybe I just began my journey with it, so it's confusing me.

I just wanted to make a simple, flexible but powerful handy Model Abstraction extension for it, mainly inspired from CodeIgniter 4.*.

Right now, I need really need some contribution. The git repo is here: https://github.com/…/nette-model

Here's what I've done/planned done so far:

  • Basic Finders (ok)
  • Advanced Finders (@todo)
  • Create, Insert, Delete (ok)
  • Soft Delete (@dev)
  • Timestamps Behavior (@dev)
  • Auto-detect Model Name (ok)
  • Entity Support(@todo)
  • Use only nette components (ok)
  • Keep it minimal but most usable (ok)
  • Hassle free usage

Give me your thoughts on it. I'll need some more time to set up the repo properly to be installed via composer.
But take look at least on the repo. Hopefully, it will be updated overtime.

2 months ago

Mabar
Member | 286
+
+4
-

I really miss an ORM built-it for it

I would recommend nextras/orm, but you may also choose doctrine/orm (integrated by nettrine)

Both of them have their own DBAL and database migrations and also integration into symfony/console (see below)

I also miss a cli in nette framework

Most of us use symfony/console (integrated via contributte/console)

The lack of implementing models in proper way is what bothered me a lot.

There are no base model classes, because they are an anti-pattern. Model is your unique business logic, not some mix of utilities you may need. Most of utilities can be in fully-separated classes.

Last edited by Mabar (2020-06-13 10:56)

2 months ago

farhanianz
Member | 8
+
0
-

That was a quick reply, I was about to ask if I'm reinventing things already made.

I really like how Contributte team is giving their effort, But the docs are rather short, very short. I was never a fan of doctrine so didn't used it. Now I feel I need something powerful, I'm tired of writing sql queries.

Looked at the neutella-project, which has a good starting point. But it assumes that I already know what to do. I wish the docs are bit explained. However I'm not asking to re-write the doctrine-project docs again but references could have given for nettrine/orm what we need to learn from the thing from doctrine-project docs.

I started it just to have a base model ready for new projects & tried to implement some of the ORMish features without dependency (except nette). I just looked at the codeigniter4/codeigniter4 repo, they have a nice clean model & entity which does most of the things without clutter. Yes, I don't think it supports explicit relationships/mappings.

The nextras/orm-demo isn't working as they are updating it to v4 (I should have created an issue there). So that led me to write a model wrapper.

However, I still need the answer, am I reinventing?

*Edit: typo

Last edited by farhanianz (2020-06-13 11:34)

2 months ago

Mabar
Member | 286
+
0
-

But the docs are rather short

Feel free to open issue, if something is missing. Many of Contributte packages are just DI (and Tracy, cache, …) integrations of popular packages like symfony/console or league/flysystem. Knowledge of integrated packages is expected, so docs are mostly about the things integration adds, not about the integrated package itself.

I was never a fan of doctrine so didn't used it. Now I feel I need something powerful, I'm tired of writing sql queries.

Then nextras/orm could make you happy. It's way easier to work with and just works :)

Looked at the neutella-project, which has a good starting point. But it assumes that I already know what to do. I wish the docs are bit explained. However I'm not asking to re-write the doctrine-project docs again but references could have given for nettrine/orm what we need to learn from the thing from doctrine-project docs.

cc @Felix

I started it just to have a base model ready for new projects & tried to implement some of the ORMish features without dependency (except nette). I just looked at the codeigniter4/codeigniter4 repo, they have a nice clean model & entity which does most of the things without clutter. Yes, I don't think it supports explicit relationships/mappings.

+

However, I still need the answer, am I reinventing?

Probably yes, you are reinventing. If you want orm then use one. Also, there is a orm-like wrapper for nette/database (YetORM), but it's not up-to-date and imho more complicated than using of orm or nette/database

The nextras/orm-demo isn't working as they are updating it to v4 (I should have created an issue there).

Just use the commit before v4 update. I am sure @hrach will update the demo to v4 once the stable is released

2 months ago

hrach
Member | 1818
+
0
-

The nextras/orm-demo isn't working as they are updating it to v4 (I should have created an issue there).

Please do so. Orm demo is already updated for Orm 4 about two months for now. :)