Skip to content

Commit 61edc21

Browse files
committed
docs: add about DevKit
1 parent 2158ffa commit 61edc21

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

user_guide_src/source/extending/composer_packages.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,76 @@ be ``YourVendor``. So you would write like the following::
8989

9090
This setting instructs Composer to autoload the source code for your package.
9191

92+
***************************
93+
Preparing Development Tools
94+
***************************
95+
96+
There are many tools that help ensure quality code. So you should use them.
97+
You can easily install and configure such tools with
98+
`CodeIgniter DevKit <https://github.com/codeigniter4/devkit>`_.
99+
100+
Installing DevKit
101+
=================
102+
103+
In the root of your package directory, run the following commands::
104+
105+
> composer config minimum-stability dev
106+
> composer config prefer-stable true
107+
> composer require --dev codeigniter4/devkit
108+
109+
The DevKit installs various Composer packages that helps your development, and
110+
installs templates for them in **vendor/codeigniter4/devkit/src/Template**.
111+
Copy the files in it to your project root folder, and edit them for your needs.
112+
113+
Configuring Coding Standards Fixer
114+
==================================
115+
116+
DevKit provides Coding Standards Fixer with
117+
`CodeIgniter Coding Standard <https://github.com/CodeIgniter/coding-standard>`_
118+
based on `PHP-CS-Fixer <https://github.com/PHP-CS-Fixer/PHP-CS-Fixer>`_.
119+
120+
Copy **vendor/codeigniter4/devkit/src/Template/.php-cs-fixer.dist.php** to your
121+
project root folder.
122+
123+
Create the **build** folder for the cache file::
124+
125+
your-package-name/
126+
├── .php-cs-fixer.dist.php
127+
├── build/
128+
129+
Open **.php-cs-fixer.dist.php** in your editor, and fix the folder path::
130+
131+
--- a/.php-cs-fixer.dist.php
132+
+++ b/.php-cs-fixer.dist.php
133+
@@ -7,7 +7,7 @@ use PhpCsFixer\Finder;
134+
$finder = Finder::create()
135+
->files()
136+
->in([
137+
- __DIR__ . '/app/',
138+
+ __DIR__ . '/src/',
139+
__DIR__ . '/tests/',
140+
])
141+
->exclude([
142+
143+
That't it. Now you can run Coding Standards Fixer::
144+
145+
> vendor/bin/php-cs-fixer fix --ansi --verbose --diff
146+
147+
If you add ``scripts.cs-fix`` in your **composer.json**, you can run it with
148+
``composer cs-fix`` command::
149+
150+
--- a/composer.json
151+
+++ b/composer.json
152+
@@ -23,5 +23,8 @@
153+
"allow-plugins": {
154+
"phpstan/extension-installer": true
155+
}
156+
+ },
157+
+ "scripts": {
158+
+ "cs-fix": "php-cs-fixer fix --ansi --verbose --diff"
159+
}
160+
}
161+
92162
************
93163
Config Files
94164
************

0 commit comments

Comments
 (0)