mykemeynell / archuser
User Layer Architecture for Laravel (Service, Repository, Entity)
Installs: 37
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- mykemeynell/archlayer: ^1.0
- mykemeynell/laraveluuid: ^1.0
README
A small package that sets up a Service, Repository and Entity for user storage. You can extend the classes and interfaces within this package to add your own additional functionality, or use the ones that come with this package as default.
Installation via Composer
- Get the latest version of ArchUser for your application.
composer require mykemeynell/archuser
- Include the service provider within your application.
... \ArchLayerUser\Provider\ArchUserServiceProvider::class, ...
- Bind the Service, Repository and Entity to your application.
public function register(): void { $this->app->bind('user.entity', \ArchLayerUser\Entity\UserEntity::class); $this->app->bind('userRole.entity', \ArchLayerUser\Entity\UserRoleEntity::class); $this->app->bind('userRolePermission.entity', \ArchLayerUser\Entity\UserRolePermissionEntity::class); $this->app->singleton('user.repository', \ArchLayerUser\Repository\UserRepository::class); $this->app->singleton('userRole.repository', \ArchLayerUser\Repository\UserRoleRepository::class); $this->app->singleton('userRolePermission.repository', \ArchLayerUser\Repository\UserRolePermissionRepository::class); $this->app->singleton('user.service', \ArchLayerUser\Service\UserService::class); $this->app->singleton('userRole.service', \ArchLayerUser\Service\UserRoleService::class); $this->app->singleton('userRolePermission.service', \ArchLayerUser\Service\UserRolePermissionService::class); }
- Register any aliases and populate your providers
provides(): void
method appropriately, I have a couple of packages atmykemeynell/laravel-alias-service
andmykemeynell/laravel-provides-service
. The following instructions are based on using those packages.
class AppServiceProvider extends ServiceProvider { use mykemeynell\Support\Providers\Concern\AliasService, mykemeynell\Support\Providers\Concern\ProvidesService; /** * Services that are to be aliased into application. * * @var array */ protected $aliases = [ 'user.entity' => [\ArchLayerUser\Entity\Contract\UserEntityInterface::class], 'userRole.entity' => [\ArchLayerUser\Entity\Contract\UserRoleEntityInterface::class], 'userRolePermission.entity' => [\ArchLayerUser\Entity\Contract\UserRolePermissionsEntityInterface::class], 'user.repository' => [\ArchLayerUser\Repository\Contract\UserRepositoryInterface::class], 'userRole.repository' > [\ArchLayerUser\Repository\Contract\UserRoleRepositoryInterface::class], 'userRolePermission.repository' => [[\ArchLayerUser\Repository\Contract\UserRolePermissionsRepositoryInterface::class]], 'user.service' => [\ArchLayerUser\Service\Contract\UserServiceInterface::class], 'userRole.service' => [\ArchLayerUser\Service\Contract\UserRoleServiceInterface::class], 'userRolePermission.service' => [\ArchLayerUser\Service\Contract\UserRolePermissionsServiceInterface::class], ]; ...
- Call the
AliasService::registerAliases(): void
method.
public function register(): void { $this->registerAliases(); ...