Skip to content

Commit b00b712

Browse files
committed
Add code style information
1 parent 068b4d4 commit b00b712

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

docs/get-started/codestyle.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,33 @@ sidebar_position: 5
33
---
44
Coding Style Guide
55
=======================
6-
This is the content for Coding Standards used in Joomla
6+
7+
Since Joomla version 4.2 Joomla is using the [PSR-12](https://www.php-fig.org/psr/psr-12/) coding standard. You can enable the coding standard in your IDE to get hints when you're violating the rules or can use an auto fix, too.
8+
We recommend that you follow this standard also when developing your own extensions to stay compatible always with core and that you don't have to switch when working with core.
9+
10+
## Install code style checker
11+
:::caution TODO
12+
Copy from https://docs.joomla.org/Joomla_CodeSniffer and update to the new version
13+
:::
14+
15+
## Use integrated checker
16+
The Joomla core system is shipping a so called "code sniffer" and a "code fixer" to check for code standard violations and to fix most (but sometimes not all) of them. This only works if you're using the full developer version from GitHub, not when you're working with a installation zip package.
17+
18+
To run the code sniffer/fixer you need to start a terminal, navigate to your Joomla root folder (the folder where your Joomla is installed) and run one of the following commands (don't forget the "."):
19+
20+
### Checking for code style violations
21+
22+
```./libraries/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .```
23+
24+
This will run the code style check for the whole Joomla! installation, including your extensions, when installed in Joomla!
25+
26+
### Fixing code style violations
27+
28+
```./libraries/vendor/bin/phpcbf --extensions=php -p --standard=ruleset.xml .```
29+
30+
This will run the code style fixer for the whole Joomla installation, including your extension. The fixer tries to fix all violation, but sometimes it can't fix all. So it's recommended to run the checker (see above) afterwards and fix the last issues manually.
31+
32+
733
:::caution TODO
834

935
This page is unfinished, please use the **Edit this Page** link at the bottom of this page to help make it more useful.

0 commit comments

Comments
 (0)