@@ -5,31 +5,123 @@ Development toolkit for CodeIgniter libraries and projects
5
5
6
6
* Install via Composer: ` > composer require --dev codeigniter4/devkit `
7
7
8
- ## Included
8
+ ## Included Dependencies
9
9
10
10
### Styles and Standards
11
11
12
12
* [ CodeIgniter Coding Standard] ( https://github.com/CodeIgniter/coding-standard )
13
- * NexusPHP CS Config
13
+ * [ NexusPHP CS Config] ( https://github.com/NexusPHP/cs-config )
14
14
15
15
### Testing and Analysis
16
16
17
- * NexusPHP Tachycardia
18
- * PHPStan
19
- * PHPUnit
17
+ * [ NexusPHP Tachycardia] ( https://github.com/NexusPHP/tachycardia )
18
+ * [ PHPStan] ( https://phpstan.org/user-guide/getting-started )
19
+ * [ PHPUnit] ( http://phpunit.readthedocs.io )
20
20
21
21
### Mocking
22
22
23
- * FakerPHP
24
- * VFS Stream
23
+ * [ FakerPHP] ( https://fakerphp.github.io )
24
+ * [ VFS Stream] ( https://github.com/bovigo/vfsStream/wiki )
25
25
26
- ## Additional Tools
26
+ ### Security
27
27
28
- These are integrated into the workflows but not included via Composer so need to be installed separately.
29
- All of them are available via [ Phive] ( https://phar.io/#Tools ) .
28
+ * [ Dependabot] ( https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates )
29
+ * [ Roave Security Advisories] ( https://github.com/Roave/SecurityAdvisories )
30
+
31
+ ### Additional Tools
32
+
33
+ These are integrated into the workflows but not included via Composer. If you want to use them
34
+ locally they will need to be installed. All of them are available via [ Phive] ( https://phar.io/#Tools ) .
30
35
31
36
* [ Composer Normalize] ( https://github.com/ergebnis/composer-normalize )
32
37
* [ Composer Unused] ( https://github.com/composer-unused/composer-unused )
38
+ * [ Deptrac] ( https://github.com/qossmic/deptrac )
33
39
* [ Infection] ( https://infection.github.io/ )
34
40
* [ PHP Coveralls] ( https://php-coveralls.github.io/php-coveralls/ )
35
41
* [ PHP CS Fixer] ( https://cs.symfony.com/ )
42
+
43
+ ## Source Files
44
+
45
+ The provided source files should be considered guidelines or templates for your own use, as
46
+ they may need changing to fit your environment. These are based on the following assumptions:
47
+
48
+ 1 . Your default repository branch is set to ` develop `
49
+ 2 . You use Composer to manage all necessary dependencies
50
+ 3 . Your source code is located in ** app/** (for projects) or ** src/** (for libraries)
51
+ 4 . Your unit tests are located in ** tests/**
52
+ 5 . Your CodeIgniter dependency is ` codeigniter4/framework ` (some paths need to be changed for ` dev-develop ` )
53
+
54
+ ### Workflows
55
+
56
+ This kit includes a number of workflow templates for integrating [ GitHub Actions] ( https://docs.github.com/en/actions )
57
+ into your library or project development process. To add these to your repo simply copy the
58
+ workflows into a ** .github/workflows/** directory.
59
+
60
+ > Hint: the [ source files] ( src/.github ) also include a configuration for Dependabot which will help keep your dependencies and workflows updated.
61
+
62
+ Below is a brief description of each workflow; see the links above for help with each tool.
63
+
64
+ #### Deptrac
65
+
66
+ * Requires ** depfile.yaml***
67
+
68
+ Deptrac is a "dependency tracing" tool that allows developers to define which components should
69
+ be allowed to access each other. This helps keep your project architecture logical and concise
70
+ by enforcing the rules you set. For example, you may want to impose an MVC-style architecture
71
+ by allowing a ` Controller ` to use any ` Model ` but not vice-versa.
72
+
73
+ #### Infection
74
+
75
+ * Requires ** infection.json.dist***
76
+
77
+ Just because your tests reach a high level of code coverage does not mean they are comprehensive.
78
+ Mutation Testing is a way of gauging the * quality* of your unit tests. A silly example: your
79
+ code has an increment function with a single unit test for 100% coverage:
80
+
81
+ ``` php
82
+ function increment(int $num1, int $num2): int
83
+ {
84
+ return $num1 + $num2;
85
+ }
86
+
87
+ function testIncrementWithZero()
88
+ {
89
+ $result = increment(42, 0);
90
+ $this->assertSame(42, $result);
91
+ }
92
+ ```
93
+
94
+ Infection will re-run your unit test against "mutated" versions of your code that * should*
95
+ cause failures and report "escaped mutations" when they still pass. In this example, Infection
96
+ mutates your ` increment() ` function to use ` - ` instead of ` + ` , but since your test case
97
+ still asserts ` 42 ` as the result it is considered an "escape" and you should plan to add
98
+ more tests.
99
+
100
+ #### PHPCPD
101
+
102
+ PHP Copy-Paste Detector analyzes your code and reports when there are blocks of duplicate code
103
+ more than a certain number of lines long (default: 5). In most cases this is a sign of poor
104
+ code structure and an opportunity to consolidate classes or functions.
105
+
106
+ #### PHPStan
107
+
108
+ * Requires ** phpstan.neon.dist***
109
+
110
+ Static analysis is a major factor in catching bugs and issues before they happen. PHPStan will
111
+ analyze your code for mistakes based on the configuration supplied.
112
+
113
+ #### PHPUnit
114
+
115
+ * Requires ** phpunit.xml.dist***
116
+
117
+ Unit testing automates running your code through all the possible scenarios before putting it
118
+ into use in production. PHPUnit is a highly-configurable framework and suite for writing and
119
+ running unit tests. This workflow also configures PHPUnit to report on code coverage and
120
+ upload the results to [ Coveralls.io] ( https://coveralls.io ) (you will need a free account,
121
+ but it is also fine to use this workflow without Coveralls).
122
+
123
+ #### Unused
124
+
125
+ Composer Unused does one thing: checks that your code actually uses the dependencies you
126
+ have included via Composer. It can be easy to forget to update your ** composer.json** when
127
+ your code drops a dependency, so this workflow will help track those down.
0 commit comments