5upermario/slim-skeleton

Skeleton app for slim framework

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

This package is auto-updated.

Last update: 2024-04-19 14:45:32 UTC


README

PHP Tests

Create project

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

Utilities

Serve application

composer serve

It runs a dev server on port 8000

Run tests

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

Watch tests

npm run watch:test

# Docker:
npm run watch:test:docker

Additional features

Event dispatcher

You can setup events and listeners in config/events.php like

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

Then you can evaluate these events with the EventDispatcher class

class ExampleClass {
    private EventDispatcher $eventDispatcher;

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

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