Difference between #21 and #22 of
Yii3 - How to start

Revision #22 has been created by rackycz rackycz on Oct 9, 2025, 10:21:18 AM with the memo:

edit
« previous (#21) next (#23) »

Changes

Title unchanged

Yii3 - How to start

Category unchanged

Tutorials

Yii version unchanged

3.0

Tags unchanged

Content changed

[...]
## Using Repository and the Model class

Each entity should have its Model class and Repository class if you are storing it in DB. Have a look at the demo application "blog-api": https://github.com/yiisoft/demo

In my case
the User model (file `src/Entity/User.php`) will only contain private attributes, setters and getters. `UserRepository` (placed in the same folder) may look like this to enable CRUD (compressed code):

```php
[...]
}
}
```

 
 
Now you can modify `IndexAction` to contain this: (read above to understand details)
 
 
```php
 
// use App\Entity\UserRepository;
 
$userRepository = $container->get(UserRepository::class);
 
return $responseFactory->success($userRepository->findAll([], true));
 
```
1 0
2 followers
Viewed: 576 times
Version: 3.0
Category: Tutorials
Tags:
Written by: rackycz rackycz
Last updated by: rackycz rackycz
Created on: Oct 8, 2025
Last updated: 2 days ago
Update Article

Revisions

View all history