Skip to content

Commit 69d1e36

Browse files
authored
Initial implementation
1 parent 31093eb commit 69d1e36

69 files changed

Lines changed: 2416 additions & 108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/bc.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
tests:
99
name: PHP ${{ matrix.php-version }}-${{ matrix.os }}
1010
env:
11-
extensions: curl, mbstring, dom, intl, json, libxml, xml, xmlwriter
11+
extensions: curl, mbstring, dom, intl, json, libxml, xml, xmlwriter, fileinfo
1212
key: cache-v1
1313

1414
runs-on: ${{ matrix.os }}

.github/workflows/mutation.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ jobs:
4646
- name: Install dependencies with composer
4747
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
4848

49-
- name: Static analysis with phan
50-
run: vendor/bin/phan --no-progress-bar --output-mode checkstyle | cs2pr --graceful-warnings --colorize
49+
- name: Static analysis with psalm
50+
run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ phpunit.phar
3333
# Phan
3434
analysis.txt
3535

36+
#tests
37+
tests/_data/database.db_snapshot

README.md

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,63 @@
22
<a href="https://github.com/yiisoft" target="_blank">
33
<img src="https://github.com/yiisoft.png" height="100px">
44
</a>
5-
<h1 align="center">Yii _____</h1>
5+
<h1 align="center">Yii API template</h1>
66
<br>
77
</p>
88

9-
[![Latest Stable Version](https://poser.pugx.org/yiisoft/_____/v/stable.png)](https://packagist.org/packages/yiisoft/_____)
10-
[![Total Downloads](https://poser.pugx.org/yiisoft/_____/downloads.png)](https://packagist.org/packages/yiisoft/_____)
11-
[![Build status](https://github.com/yiisoft/_____/workflows/build/badge.svg)](https://github.com/yiisoft/_____/actions?query=workflow%3Abuild)
12-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/_____/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/_____/?branch=master)
13-
[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/_____/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/_____/?branch=master)
14-
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2F_____%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/_____/master)
15-
[![static analysis](https://github.com/yiisoft/_____/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/_____/actions?query=workflow%3A%22static+analysis%22)
9+
[![Latest Stable Version](https://poser.pugx.org/yiisoft/app-api/v/stable.png)](https://packagist.org/packages/yiisoft/app-api)
10+
[![Total Downloads](https://poser.pugx.org/yiisoft/app-api/downloads.png)](https://packagist.org/packages/yiisoft/app-api)
11+
[![Build status](https://github.com/yiisoft/app-api/workflows/build/badge.svg)](https://github.com/yiisoft/app-api/actions?query=workflow%3Abuild)
12+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/app-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/app-api/?branch=master)
13+
[![static analysis](https://github.com/yiisoft/app-api/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/app-api/actions?query=workflow%3A%22static+analysis%22)
1614

17-
The package ...
15+
API application template for Yii 3.
1816

1917
## Installation
2018

21-
The package could be installed with composer:
19+
Install docker:
2220

2321
```
24-
composer install yiisoft/_____
22+
docker-compose up -d
2523
```
2624

27-
## General usage
25+
Enter into the container:
2826

29-
## Unit testing
27+
```
28+
docker exec -it yii-php bash
29+
```
3030

31-
The package is tested with [PHPUnit](https://phpunit.de/). To run tests:
31+
Install packages:
3232

33-
```php
34-
./vendor/bin/phpunit
3533
```
34+
composer install
35+
```
36+
37+
Usually the application is available at http://localhost:8080.
3638

37-
## Mutation testing
39+
### Endpoints:
3840

39-
The package tests are checked with [Infection](https://infection.github.io/) mutation framework. To run it:
41+
| Method | Requires auth | Description |
42+
| :--------------- |:--------------| :--------------------|
43+
| GET / | no | get application info |
44+
| GET /blog/ | no | get blog records |
45+
| GET /blog/[id] | no | get blog record |
46+
| POST /blog/ | yes | create blog record |
47+
| PUT /blog/[id] | yes | update blog record |
48+
| GET /users/ | yes | get users |
49+
| GET /users/[id] | yes | get user |
50+
| POST /auth/ | no | auth |
51+
52+
Authorization is performed via the `X-Api-Key` header.
53+
54+
55+
## Codeception testing
4056

4157
```php
42-
./vendor/bin/infection
58+
./vendor/bin/codecept run
4359
```
4460

61+
4562
## Static analysis
4663

4764
The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

codeception.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace: App\Tests
2+
paths:
3+
tests: tests
4+
output: tests/_output
5+
data: tests/_data
6+
support: tests/_support
7+
envs: tests/_envs
8+
actor_suffix: Tester
9+
extensions:
10+
enabled:
11+
- Codeception\Extension\RunFailed

composer.json

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,118 @@
11
{
2-
"name": "yiisoft/_____",
3-
"type": "library",
4-
"description": "_____",
2+
"name": "yiisoft/app-api",
3+
"type": "project",
4+
"description": "Yii Framework API project template",
55
"keywords": [
6-
"_____"
6+
"yii3",
7+
"app",
8+
"api",
9+
"rest"
710
],
8-
"homepage": "https://www.yiiframework.com/",
11+
"homepage": "https://github.com/yiisoft/app-api/",
912
"license": "BSD-3-Clause",
1013
"support": {
11-
"issues": "https://github.com/yiisoft/_____/issues?state=open",
14+
"issues": "https://github.com/yiisoft/app-api/issues?state=open",
1215
"forum": "https://www.yiiframework.com/forum/",
1316
"wiki": "https://www.yiiframework.com/wiki/",
1417
"irc": "irc://irc.freenode.net/yii",
15-
"source": "https://github.com/yiisoft/_____"
18+
"source": "https://github.com/yiisoft/app-api"
1619
},
1720
"minimum-stability": "dev",
1821
"prefer-stable": true,
1922
"require": {
20-
"php": "^7.4|^8.0"
21-
},
22-
"require-dev": {
23-
"infection/infection": "^0.16.3",
24-
"phpunit/phpunit": "^9.3",
25-
"vimeo/psalm": "^3.16"
23+
"php": "^7.4|^8.0",
24+
"cebe/markdown": "^1.2@dev",
25+
"cycle/orm": "^1.2",
26+
"cycle/proxy-factory": "^1.2",
27+
"myclabs/php-enum": "^1.7",
28+
"nyholm/psr7": "^1.0",
29+
"psr/container": "^1.0",
30+
"psr/http-factory": "^1.0",
31+
"psr/http-message": "^1.0",
32+
"psr/http-server-handler": "^1.0",
33+
"psr/http-server-middleware": "^1.0",
34+
"psr/log": "^1.1",
35+
"yiisoft/access": "^1.0",
36+
"yiisoft/aliases": "^1.0",
37+
"yiisoft/arrays": "^3.0@dev",
38+
"yiisoft/auth": "^1.0",
39+
"yiisoft/cache": "^3.0@dev",
40+
"yiisoft/cache-file": "^3.0@dev",
41+
"yiisoft/composer-config-plugin": "^1.0@dev",
42+
"yiisoft/data": "^3.0@dev",
43+
"yiisoft/data-response": "^3.0@dev",
44+
"yiisoft/di": "^3.0@dev",
45+
"yiisoft/factory": "^3.0@dev",
46+
"yiisoft/http": "^1.0@dev",
47+
"yiisoft/injector": "^1.0",
48+
"yiisoft/json": "^1.0",
49+
"yiisoft/log": "^3.0@dev",
50+
"yiisoft/log-target-file": "^3.0@dev",
51+
"yiisoft/request-body-parser": "^3.0@dev",
52+
"yiisoft/request-model": "^1.0@dev",
53+
"yiisoft/router": "^3.0@dev",
54+
"yiisoft/router-fastroute": "^3.0@dev",
55+
"yiisoft/security": "^1.0",
56+
"yiisoft/serializer": "^3.0@dev",
57+
"yiisoft/strings": "^1.0",
58+
"yiisoft/validator": "^3.0@dev",
59+
"yiisoft/var-dumper": "^3.0@dev",
60+
"yiisoft/yii-console": "^3.0@dev",
61+
"yiisoft/yii-cycle": "^3.0@dev",
62+
"yiisoft/yii-debug": "^3.0@dev",
63+
"yiisoft/yii-event": "^3.0@dev",
64+
"yiisoft/yii-web": "^3.0@dev"
2665
},
2766
"autoload": {
2867
"psr-4": {
29-
"Yiisoft\\_____\\": "src"
68+
"App\\": "src"
3069
}
3170
},
3271
"autoload-dev": {
3372
"psr-4": {
34-
"Yiisoft\\_____\\Tests\\": "tests"
73+
"App\\Tests\\": "tests/",
74+
"App\\Tests\\Acceptance\\": "tests/acceptance/"
3575
}
3676
},
77+
"scripts": {
78+
"post-update-cmd": [
79+
"App\\Installer::postUpdate"
80+
]
81+
},
3782
"extra": {
3883
"branch-alias": {
39-
"dev-master": "3.0.x-dev"
84+
"dev-master": "1.0.x-dev"
85+
},
86+
"config-plugin-output-dir": "runtime/build/config",
87+
"config-plugin": {
88+
"common": "config/common.php",
89+
"web": [
90+
"$common",
91+
"config/web.php"
92+
],
93+
"params": [
94+
"config/params.php",
95+
"?config/params-local.php"
96+
],
97+
"providers": "config/providers.php",
98+
"events": "config/events.php"
99+
},
100+
"config-plugin-alternatives": {
101+
"tests": {
102+
"params": "config/params-test.php"
103+
}
40104
}
41105
},
42106
"config": {
43107
"sort-packages": true
108+
},
109+
"require-dev": {
110+
"codeception/codeception": "^4.1",
111+
"codeception/lib-innerbrowser": "^1.3",
112+
"codeception/module-asserts": "^1.0.0",
113+
"codeception/module-db": "^1.0",
114+
"codeception/module-phpbrowser": "^1.0.0",
115+
"codeception/module-rest": "^1.2",
116+
"vimeo/psalm": "^4.0"
44117
}
45118
}

config/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*-local.php

config/common.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use App\Factory\AppRouterFactory;
4+
use Psr\Container\ContainerInterface;
5+
use Yiisoft\Router\FastRoute\UrlGenerator;
6+
use Yiisoft\Router\Group;
7+
use Yiisoft\Router\RouteCollectorInterface;
8+
use Yiisoft\Router\UrlGeneratorInterface;
9+
use Yiisoft\Router\UrlMatcherInterface;
10+
11+
/**
12+
* @var array $params
13+
*/
14+
15+
return [
16+
ContainerInterface::class => static function (ContainerInterface $container) {
17+
return $container;
18+
},
19+
RouteCollectorInterface::class => Group::create(),
20+
UrlMatcherInterface::class => new AppRouterFactory(),
21+
UrlGeneratorInterface::class => UrlGenerator::class,
22+
];

0 commit comments

Comments
 (0)