22
33## Conventions
44
5- * PHP version 8.3.
6- * All files are required to be linted with PSR-12 standard.
7- * The maximum line length for any PHP file is 100 characters, instead of PSR-12's 120 characters.
8- * Comments should be used sparingly.
9- * Empty lines should be used sparingly.
10- * No code should fail quietly, instead exceptions should be thrown.
5+ - PHP version 8.3.
6+ - All pure PHP files are required to be formatted with Prettier.
7+ - All impure PHP files (mixed into HTML) are required to be linted with PSR-12 and formatted with ` phpcbf ` .
8+ - The maximum line length for any PHP file is 100 characters.
9+ - Comments should be used sparingly.
10+ - Empty lines should be used sparingly.
11+ - No code should fail quietly, instead exceptions should be thrown.
1112 PHP builtin functions that fail quietly (ex: ` json_encode ` ) should be replaced with a wrapper in ` resources/utils.php ` .
12- * No code should call ` die() ` or ` exit() ` , instead ` UnityHTTPD::die() ` .
13+ - No code should call ` die() ` or ` exit() ` , instead ` UnityHTTPD::die() ` .
1314 This will avoid the premature death of our automated testing processes.
14- * No code should call ` assert() ` , instead ` \ensure() ` .
15+ - No code should call ` assert() ` , instead ` \ensure() ` .
1516 This will enforce conditions even in production.
16- * No code should call ` json_encode() ` , instead ` \jsonEncode() ` .
17+ - No code should call ` json_encode() ` , instead ` \jsonEncode() ` .
1718 This will throw errors and escape slashes by default.
18- * No code should call ` mb_convert_encoding() ` , instead ` \mbConvertEncoding() ` .
19+ - No code should call ` mb_convert_encoding() ` , instead ` \mbConvertEncoding() ` .
1920 This will throw an exception rather than returning ` false ` .
20- * No code should call ` mb_detect_encoding() ` , instead ` \mbDetectEncoding() ` .
21+ - No code should call ` mb_detect_encoding() ` , instead ` \mbDetectEncoding() ` .
2122 This will enable strict mode and throw an exception rather than returning ` false ` .
22- * ` UnityHTTPD ` 's user-facing error functionality (ex: ` badRequest ` ) should only be called from ` webroot/**/*.php ` .
23+ - ` UnityHTTPD ` 's user-facing error functionality (ex: ` badRequest ` ) should only be called from ` webroot/**/*.php ` .
2324 ` resources/**/*.php ` should throw exceptions instead.
2425
2526This repository will automatically check PRs for linting compliance.
@@ -29,6 +30,7 @@ This repository will automatically check PRs for linting compliance.
2930### Setting up your Environment
3031
31321 . Clone this repo (including submodules): ` git clone <this-repo> --recurse-submodules `
33+ 1 . Install php v8.3
32341 . install [ composer] ( https://getcomposer.org/ )
33351 . install PHP dependencies: ` composer update `
34361 . If you're on Windows, use [ WSL] ( https://learn.microsoft.com/en-us/windows/wsl/ )
@@ -38,15 +40,17 @@ This repository will automatically check PRs for linting compliance.
38401 . Install [ pre-commit] ( https://pre-commit.com/ )
39411 . setup pre-commit hooks: ` pre-commit install `
40421 . Install modern implementation of grep (not macOS builtin grep): ` brew install grep `
43+ 1 . Install ` npm `
44+ 1 . Install nodeJS tools: ` npm install `
4145
4246### Environment Usage
4347
4448While the environment is running, the following is accessible:
4549
46- * http://127.0.0.1:8000 - Web Portal
47- * http://127.0.0.1:8010 - PHPLDAPAdmin Portal
48- * http://127.0.0.1:8020 - PHPMyAdmin Portal
49- * http://127.0.0.1:8030 - Mailcatcher Portal
50+ - http://127.0.0.1:8000 - Web Portal
51+ - http://127.0.0.1:8010 - PHPLDAPAdmin Portal
52+ - http://127.0.0.1:8020 - PHPMyAdmin Portal
53+ - http://127.0.0.1:8030 - Mailcatcher Portal
5054
5155### Test Users
5256
@@ -55,9 +59,10 @@ When accessing locked down portions of the portal, you will be asked for a usern
5559The password is always ` password ` . ` tools/docker-dev/web/htpasswd ` contains all valid usernames.
5660
5761Notable users:
58- 59- * ` [email protected] ` - not admin, not PI
60- * ` [email protected] ` - does not yet have an account
62+
63+ 64+ - ` [email protected] ` - not admin, not PI
65+ - ` [email protected] ` - does not yet have an account
6166
6267### Changes to Dev Environment
6368
@@ -86,13 +91,15 @@ Once a user action has been taken, internal interfaces are used to verify the re
8691To run ` phpunit ` , spawn 2 shells in differnt tabs:
8792
8893tab 1:
94+
8995``` shell
9096cd ./tools/docker-dev
9197./build.sh
9298./run.sh
9399```
94100
95101tab 2:
102+
96103```
97104$ container="$(docker container ls | grep web | awk '{print $1}')"
98105$ docker exec -it "$container" bash
@@ -138,6 +145,7 @@ When writing a test, it may be tempting to use the PHP API directly, but the HTT
138145Example:
139146
140147using the PHP API:
148+
141149``` php
142150private function requestGroupCreation()
143151{
@@ -146,6 +154,7 @@ private function requestGroupCreation()
146154```
147155
148156using the HTTP API:
157+
149158``` php
150159private function requestGroupCreation()
151160{
0 commit comments