monarc / backoffice
monarc/monarc-backoffice应用程序的后台管理
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- ext-pdo: *
- doctrine/doctrine-orm-module: ^5.1
- laminas/laminas-dependency-plugin: ^2.0
- laminas/laminas-di: ^3.1
- laminas/laminas-mvc: ^3.1
- laminas/laminas-permissions-rbac: ^3.0
- monarc/core: ^2.12.6
- robmorgan/phinx: ^0.13.4
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-13 11:22:25 UTC
README
查看示例存储库以创建
- 实体
- 实体表
- 控制器
- 控制器工厂
- 服务
- 服务工厂
- 并配置Module.php & module.config.php
实体
在Model/Entity文件夹中创建实体文件和类,并使用AbstractEntity
扩展它。
定义protected
属性,并使用DoctrineOrm来定义表和列。
在Module.php:getServiceConfig()
中,将它们添加到invokables
'\Monarc\Core\Model\Entity\MyEntity' => '\Monarc\Core\Model\Entity\MyEntity',
用于生成迁移文件和迁移数据库(添加/删除/更改列)
php ./vendor/bin/doctrine-module migrations:diff
php ./vendor/bin/doctrine-module migrations:migrate
实体表
在Model/Table文件夹中创建实体表文件和类,并使用AbstractEntityTable
扩展它。
定义您自己的函数,用于从数据库中加载数据实体。AbstractEntityTable已经具有这些函数
- getDb: 返回DB对象
- fetchAll: 返回实体的所有数据
- get: 返回实体
- save
- delete
在Module.php:getServiceConfig()
中,将它们添加到factories
'\Monarc\Core\Model\Table\MyEntityTable' => function($sm){
return new Model\Table\MyEntityTable($sm->get('\Monarc\Core\Model\Db'));
},
控制器
在Controller文件夹中创建控制器文件和类,并使用AbstractController
扩展。
添加功能
- getList()
- get($id)
- create($data)
- update($id, $data)
- delete($id)
在module.config.php
中,定义路由和控制器
'controller' => '\Monarc\Core\Controller\MyIndex',
控制器工厂
在Controller文件夹中创建控制器工厂文件和类,并使用AbstractControllerFactory
扩展。
定义protected $serviceName = '\Monarc\Core\Service\MyService';
。
在Module.php:getControllerConfig()
中,将它们添加到factories
'\Monarc\Core\Controller\MyIndex' => '\Monarc\Core\Controller\MyIndexControllerFactory',
服务
在Service文件夹中创建服务文件和类,并使用AbstractService
扩展。
定义在此服务中使用的资源属性
protected $ressource1;
protected $ressource2;
以及业务函数。
用于访问资源
$this->get('ressource1');
或
$this->getServiceFactory();
服务工厂
在Service Factory文件夹中创建服务文件和类,并使用AbstractServiceFactory
扩展。
定义在Service中加载的资源
protected $ressources = array(
'ressource1'=> '\Monarc\Core\Model\Table\EntityTable',
'ressource2'=> '\Monarc\Core\Model\Entity\Entity',
);
或
protected $ressources = '\Monarc\Core\Model\Table\EntityTable';
在Module.php:getServiceConfig()
中,将它们添加到factories
'\Monarc\Core\Service\MyIndexService' => '\Monarc\Core\Service\MyIndexServiceFactory',
许可协议
本软件根据GNU Affero General Public License版本3许可。
- 版权(C)2016-2018 Jérôme Lombardi - https://github.com/jerolomb
- 版权(C)2016-2018 Juan Rocha - https://github.com/jfrocha
- 版权(C)2016-2018 SMILE gie securitymadein.lu
- 版权(C)2017-2018 Cédric Bonhomme - https://github.com/cedricbonhomme
- 版权(C)2016-2017 Guillaume Lesniak
- 版权(C)2016-2017 Thomas Metois
- 版权(C)2016-2017 Jérôme De Almeida
有关更多信息,请参阅作者和贡献者列表。
免责声明:本程序分发时,希望它将是有用的,但没有任何保证;甚至没有关于其商誉或适合特定用途的暗示性保证。有关详细信息,请参阅GNU Affero General Public License。