Merge pull request #5040 from docjyJ/main

Improve the development environment
This commit is contained in:
Simon L. 2024-07-26 18:01:13 +02:00 committed by GitHub
commit 73e4ea26ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 2101 additions and 155 deletions

View file

@ -28,7 +28,6 @@ jobs:
run: |
set -x
cd php
composer global require wapmorgan/php-deprecation-detector dev-master
composer install
composer run php-deprecation-detector | tee -i ./phpdd.log
if grep "Total issues:" ./phpdd.log; then

View file

@ -23,9 +23,8 @@ jobs:
run: |
set -x
cd php
composer global require vimeo/psalm --prefer-dist --no-progress --dev
composer install
composer run psalm -- --monochrome --no-progress --output-format=text --update-baseline
composer run psalm:update-baseline
git clean -f lib/composer
git checkout composer.json composer.lock lib/composer
continue-on-error: true

View file

@ -42,6 +42,5 @@ jobs:
run: |
set -x
cd php
composer global require vimeo/psalm --prefer-dist --no-progress --dev
composer install
composer run psalm

View file

@ -13,7 +13,7 @@ on:
permissions:
contents: read
concurrency:
concurrency:
group: lint-twig-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
@ -36,7 +36,5 @@ jobs:
- name: twig lint
run: |
cd php
composer require sserbin/twig-linter:@dev --no-progress --dev
composer install
chmod +x ./vendor/bin/twig-linter
./vendor/bin/twig-linter lint ./templates
composer run lint:twig

11
.gitignore vendored
View file

@ -1,8 +1,13 @@
.DS_Store
/php/data/containers.json
/php/data/configuration.json
/php/data/backupsecret.json
.idea/
*.iml
/php/data/*
/php/session/*
!/php/data/.gitkeep
!/php/session/.gitkeep
/php/vendor
/manual-install/*.conf
!/manual-install/sample.conf
/manual-install/docker-compose.yml

View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mastercontainer.iml" filepath="$PROJECT_DIR$/.idea/mastercontainer.iml" />
</modules>
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

3
php/.gitignore vendored
View file

@ -1,3 +0,0 @@
/php/data/configuration.json
/php/data/containers.json

View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View file

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="AIO\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-server-middleware" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
<excludeFolder url="file://$MODULE_DIR$/vendor/http-interop/http-factory-guzzle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-server-handler" />
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/slim" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/fast-route" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/opis/closure" />
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/slim-bridge" />
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/invoker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/php-di" />
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/phpdoc-reader" />
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/twig-view" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/aio.iml" filepath="$PROJECT_DIR$/.idea/aio.iml" />
</modules>
</component>
</project>

View file

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/psr/http-server-middleware" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/http-interop/http-factory-guzzle" />
<path value="$PROJECT_DIR$/vendor/psr/http-server-handler" />
<path value="$PROJECT_DIR$/vendor/slim/slim" />
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
<path value="$PROJECT_DIR$/vendor/nikic/fast-route" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/opis/closure" />
<path value="$PROJECT_DIR$/vendor/php-di/slim-bridge" />
<path value="$PROJECT_DIR$/vendor/php-di/invoker" />
<path value="$PROJECT_DIR$/vendor/php-di/php-di" />
<path value="$PROJECT_DIR$/vendor/php-di/phpdoc-reader" />
<path value="$PROJECT_DIR$/vendor/slim/twig-view" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.4">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View file

@ -4,13 +4,60 @@ This is the code for the PHP Docker controller.
## How to run
Running this locally requires Docker Engine on the same machine.
If this is the case, just execute the following command:
Running this locally requires :
```
composer install --no-dev
cd public/
php -S 0.0.0.0:8080
### 1. Install the development environment
This project uses Composer as dependency management software. It is very similar to NPM.
The command to install all dependencies is:
```bash
composer install
```
You can then access the web interface at `localhost:8080`.
### 2. Access to docker socket
The `root` user has all privileges including access to the Docker socket.
But **it is not recommended to launch the local instance with full privileges**, consider the docker group for docker access without being `root`.
See https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
### 3. Run a `nextcloud-aio-mastercontainer` container
This application manages containers, including its own container.
So you need to run a `nextcloud-aio-mastercontainer` container for the application to work properly.
Here is a command to quickly launch a container :
```bash
docker run \
--rm \
--name nextcloud-aio-mastercontainer \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
nextcloud/all-in-one:latest
```
### 4. Start your server
With this command you will launch the server:
```bash
# Make sure to launch this command with a user having access to the docker socket.
SKIP_DOMAIN_VALIDATION=true composer run dev
```
You can then access the web interface at http://localhost:8080.
Note: You can restart the server by preceding the command with other environment variables.
## Composer routine
| Command | Description |
|-----------------------------------------|----------------------------------------|
| `composer run dev` | Starts the development server |
| `composer run psalm` | Run Psalm static analysis |
| `composer run psalm:update-baseline` | Run Psalm with `--update-baseline` arg |
| `composer run lint` | Run PHP Syntax check |
| `composer run lint:twig` | Run Twig Syntax check |
| `composer run php-deprecation-detector` | Run PHP Deprecation Detector |

View file

@ -1,6 +1,6 @@
{
"autoload": {
"psr-4": {
"psr-4": {
"AIO\\": ["src/"]
}
},
@ -18,10 +18,20 @@
"slim/csrf": "^1.3",
"ext-apcu": "*"
},
"require-dev": {
"sserbin/twig-linter": "@dev",
"vimeo/psalm": "^5.25",
"wapmorgan/php-deprecation-detector": "dev-master"
},
"scripts": {
"dev": [
"Composer\\Config::disableProcessTimeout",
"php -S localhost:8080 -t public"
],
"psalm": "psalm --threads=1",
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
"lint": "find . -name \\*.php -not -path './vendor/*' -exec php -l {} \\;",
"php-deprecation-detector": "find . -name \\*.php -not -path './vendor/*' -exec phpdd scan {} -n -t 8.3 \\;"
"psalm:update-baseline": "psalm --threads=1 --monochrome --no-progress --output-format=text --update-baseline",
"lint": "php -l src/*.php src/**/*.php public/index.php",
"lint:twig": "twig-linter lint ./templates",
"php-deprecation-detector": "phpdd scan -n -t 8.3 src/*.php src/**/*.php public/index.php"
}
}

2025
php/composer.lock generated

File diff suppressed because it is too large Load diff