5upermario/slim-skeleton

slim框架的骨架应用

安装: 15

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 1

类型:模板

v1.0.2 2021-08-08 12:39 UTC

This package is auto-updated.

Last update: 2024-09-19 15:42:51 UTC


README

PHP Tests

创建项目

composer create-project 5upermario/slim-skeleton project-name

# Docker:
docker run --rm --interactive --tty --volume $PWD:/app --volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp composer create-project 5upermario/slim-skeleton project-name

工具

运行应用服务器

composer serve

它在8000端口运行开发服务器

运行测试

composer test
# Or
npm run test

# Docker:
docker run --rm --interactive --tty --volume $PWD:/app --volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp composer test
# Or
npm run test:docker

监视测试

npm run watch:test

# Docker:
npm run watch:test:docker

其他功能

事件调度器

您可以在config/events.php中设置事件和监听器,例如

return [
    \App\Example\Domain\Event\SomeEvent::class => [
        \App\Example\Domain\Event\SomeListener1::class,
        \App\Example\Domain\Event\SomeListener2::class,
    ],
];

然后您可以使用EventDispatcher类评估这些事件

class ExampleClass {
    private EventDispatcher $eventDispatcher;

    public function __construct(EventDispatcher $eventDispatcher) {
        $this->eventDispatcher = $eventDispatcher;
    }

    public function someFunction() {
        $this->eventDispatcher->dispatch(new SomeEvent());
    }
}