Compare commits

..

86 commits

Author SHA1 Message Date
88ec33ff1a
Update CHANGELOG.md and Configuration class to use LogLib2
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release-executable (push) Waiting to run
CI / debug-executable (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
- Added entry for version 1.1.7 in CHANGELOG.md
- Updated remote references for dependencies
- Changed logger implementation in Configuration class to use LogLib2
2025-03-14 15:00:35 -04:00
bf71326090
Updated README.md
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release-executable (push) Waiting to run
CI / debug-executable (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
2025-03-11 14:24:20 -04:00
netkas
936485dde7 - Added a new constructor parameter called path which is an optional parameter that allows you to specify the path to
the configuration files directory. If not specified the library will proceed with resolving
   the path to the configuration files directory using the default method. This will override
   the `CONFIGLIB_PATH` environment variable if it is set.
 - Changed properties to become typed properties
2025-01-07 21:14:03 -05:00
netkas
6966fd39d0 Bumped version to 1.1.6 2025-01-07 21:08:11 -05:00
netkas
09b2e88e1c Updated CHANGELOG.md 2024-12-27 15:33:59 -05:00
netkas
561064261c Version fast-forward 2024-12-27 15:32:00 -05:00
netkas
faad3e69de Minor correction 2024-12-27 15:30:08 -05:00
netkas
9e97a6d414 Refactor build process and streamline executable handling 2024-12-27 15:27:57 -05:00
netkas
015f13bf12 Updated CHANGELOG.md 2024-12-27 15:25:49 -05:00
netkas
514d527923 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	.idea/php.xml
#	CHANGELOG.md
#	project.json
#	src/ConfigLib/Configuration.php
2024-12-27 15:25:30 -05:00
netkas
28d67deaa8 Deleted unused ci.yml 2024-10-29 00:30:11 -04:00
netkas
3285bec11f Merge remote-tracking branch 'origin/master'
# Conflicts:
#	.github/workflows/ci.yml
#	Makefile
2024-10-29 00:27:32 -04:00
netkas
37a8918198 Updated CHANGELOG.md 2024-10-29 00:26:37 -04:00
netkas
8d6a2c33bd Fixed regex pattern for configuration properties being considered invalid when they contain an underscore. 2024-10-29 00:26:37 -04:00
netkas
6b446ce54a Bumped version to 1.1.4 2024-10-29 00:26:37 -04:00
e704df03df Updated Build System 2024-10-29 00:26:37 -04:00
a7395e4663 Updated Build System 2024-10-29 00:26:37 -04:00
d309385993 Updated Build System 2024-10-29 00:26:37 -04:00
655eca1695 Updated build system 2024-10-29 00:26:37 -04:00
1bcd09cc1e Updated .gitignore 2024-10-29 00:26:37 -04:00
dea75c9eeb Updated build system 2024-10-29 00:26:37 -04:00
5b6be331f0 Updated .gitignore 2024-10-29 00:26:37 -04:00
d56d940da2 Updated build system 2024-10-29 00:26:37 -04:00
1f9c5576e0 Updated build system 2024-10-29 00:26:37 -04:00
876a33ffc7 Added phpdoc.dist.xml 2024-10-29 00:26:37 -04:00
b9679d168f Updated build system 2024-10-29 00:26:37 -04:00
4b05581bb6 Updated build system 2024-10-29 00:26:37 -04:00
742be22eac Bumped Version 2024-10-29 00:26:37 -04:00
aa6dca302f Added upload-dcs stage 2024-10-29 00:26:37 -04:00
b19eeb6720 Updated Build System 2024-10-29 00:26:37 -04:00
netkas
ff2296c786 Fix configuration path resolution and add setup script 2024-10-29 00:26:37 -04:00
netkas
2c05ae8b3c Updated CHANGELOG.md 2024-10-29 00:26:37 -04:00
netkas
beb133dc75 Update version and improve config validation 2024-10-29 00:26:35 -04:00
netkas
6eb1f68f98 Updated ci.yml 2024-10-29 00:26:33 -04:00
netkas
26d2b0acd8 Remove redundant --build-source flag from build steps 2024-10-29 00:26:33 -04:00
netkas
cfbbed5c4a Add --build-source flag to ncc build commands 2024-10-29 00:26:30 -04:00
netkas
230f865093 Updated CHANGELOG.md 2024-10-29 00:26:23 -04:00
e4c494ef58 Bumped version to 1.1.1 2024-10-29 00:26:07 -04:00
376e334cb5 Added upload-docs stage 2024-10-29 00:26:07 -04:00
3c89ebe4a1 Updated Build System 2024-10-29 00:26:07 -04:00
539a180f76 Updated Build System 2024-10-29 00:26:07 -04:00
netkas
6660af9fda Add --path option to display configuration storage path 2024-10-29 00:26:07 -04:00
netkas
02d1cdc8d0 Upgrade PHP configuration to version 8.3 2024-10-29 00:26:07 -04:00
netkas
c51ee499be Refactor Makefile for flexibility and maintenance 2024-10-29 00:26:07 -04:00
netkas
a223dabc28 Updated .gitignore 2024-10-29 00:26:07 -04:00
netkas
58cc299536 Add exit check and update project include paths 2024-10-29 00:26:07 -04:00
netkas
93db7fcd2c Removed test.yml 2024-10-29 00:26:07 -04:00
netkas
ed6d1f191c Refactor temp directory handling and add getVersion method 2024-10-29 00:26:07 -04:00
netkas
389b38283e Fix case inconsistency in project.json configuration schema 2024-10-29 00:26:07 -04:00
Netkas
0caabd860d Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
0f6980bc8a Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
14dfb45e98 Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
58ddce6918 Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
12acabe9b1 Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
ad4805643b Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
2d7c840468 Update test.yml 2024-10-29 00:26:07 -04:00
Netkas
f9d96524e9 Create test.yml 2024-10-29 00:26:07 -04:00
netkas
76ca3f5290 Updated CHANGELOG.md 2024-10-29 00:23:18 -04:00
netkas
0d823c88e7 Fixed regex pattern for configuration properties being considered invalid when they contain an underscore. 2024-10-29 00:23:02 -04:00
netkas
e96695a5d8 Bumped version to 1.1.4 2024-10-25 20:01:15 -04:00
65125c496a Updated Build System 2024-10-13 14:41:27 -04:00
cd4ea10fd6 Updated Build System 2024-10-13 14:35:54 -04:00
bb4a93a364 Updated Build System 2024-10-13 14:32:41 -04:00
2c33fa2f49 Updated build system 2024-10-13 14:26:02 -04:00
8dc2d1c70d Updated .gitignore 2024-10-13 14:23:36 -04:00
56f57f89de Updated build system 2024-10-13 14:23:16 -04:00
19935179a0 Updated .gitignore 2024-10-13 14:17:27 -04:00
1eae8df0e3 Updated build system 2024-10-13 14:17:17 -04:00
371c486c4f Updated build system 2024-10-13 13:37:02 -04:00
7411563758 Added phpdoc.dist.xml 2024-10-13 13:33:37 -04:00
84ad9a9fb3 Updated build system 2024-10-13 13:32:34 -04:00
870a8d6b4e Updated build system 2024-10-13 13:26:57 -04:00
ec741fd3ef Bumped Version 2024-10-13 12:50:47 -04:00
3cf70a1f2b Added upload-dcs stage 2024-10-13 12:50:03 -04:00
a19f372150 Updated Build System 2024-10-13 12:49:20 -04:00
af03b4ffda Merge branch 'master' into dev
# Conflicts:
#	.github/workflows/ci.yml
#	CHANGELOG.md
#	Makefile
#	project.json
2024-10-13 12:48:50 -04:00
94ba9a93df Bumped version to 1.1.1 2024-10-13 12:48:02 -04:00
2fd12137ae Added upload-docs stage 2024-10-13 12:46:52 -04:00
b568f75d0b Updated Build System 2024-10-13 12:39:36 -04:00
d75fbd72d2 Updated Build System 2024-10-12 20:52:22 -04:00
netkas
b8e83d31bc Fix configuration path resolution and add setup script 2024-09-27 13:18:53 -04:00
badPointer
02d6c75bf3 chore: fix artifacts again 2024-09-17 19:20:51 +00:00
badPointer
b5c7d08e57 chore: fix stages 2024-09-17 19:17:51 +00:00
badPointer
6420b9bfed chore: fix artifact pass 2024-09-17 19:15:48 +00:00
badPointer
bdf6021953 feat: add test stage 2024-09-17 19:12:50 +00:00
badPointer
287d86e9e9 chore: fix builds 2024-09-17 19:08:43 +00:00
15 changed files with 835 additions and 224 deletions

View file

@ -1,158 +0,0 @@
name: CI
on:
push:
branches:
- 'master'
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config release --log-level debug
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ncc-build
path: build/release/net.nosial.configlib.ncc
test:
needs: build
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for phpunit.xml
id: file_check
run: |
if [ -f phpunit.xml ]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Skip if no phpunit.xml
if: steps.file_check.outputs.exists == 'false'
run: exit 78
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ncc-build
path: ncc-build # Adjust this to download the artifact directly under 'ncc-build'
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
install-php-extensions zip
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Install NCC packages
run: |
ncc package install --package="ncc-build/net.nosial.configlib.ncc" --build-source --reinstall -y --log-level debug
- name: Run PHPUnit tests
run: |
wget https://phar.phpunit.de/phpunit-11.3.phar
php phpunit-11.3.phar --configuration phpunit.xml
release:
needs: [build, test]
permissions: write-all
runs-on: ubuntu-latest
container:
image: php:8.3
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ncc-build
path: ncc-build
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
ncc-build/net.nosial.configlib.ncc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

552
.github/workflows/ncc_workflow.yml vendored Normal file
View file

@ -0,0 +1,552 @@
name: CI
on:
push:
branches:
- '**'
release:
types: [created]
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config release --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: release
path: build/release/net.nosial.configlib.ncc
debug:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config debug --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: debug
path: build/debug/net.nosial.configlib.ncc
release-executable:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config release-executable --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: release-executable
path: build/release/release_executable_gz
debug-executable:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config debug-executable --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: debug-executable
path: build/debug/debug_executable_gz
release_executable:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config release_executable --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: release_executable
path: build/release/ConfigLib
debug_executable:
runs-on: ubuntu-latest
container:
image: php:8.3
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Build project
run: |
ncc build --config debug_executable --build-source --log-level debug
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: debug_executable
path: build/debug/ConfigLib
# Checking for phpunit.xml
check-phpunit:
runs-on: ubuntu-latest
outputs:
phpunit-exists: ${{ steps.check.outputs.phpunit-exists }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for phpunit.xml
id: check
run: |
if [ -f phpunit.xml ]; then
echo "phpunit-exists=true" >> $GITHUB_OUTPUT
else
echo "phpunit-exists=false" >> $GITHUB_OUTPUT
fi
# Checking for phpdoc.dist.xml
check-phpdoc:
runs-on: ubuntu-latest
outputs:
phpdoc-exists: ${{ steps.check.outputs.phpdoc-exists }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for phpdoc.dist.xml
id: check
run: |
if [ -f phpdoc.dist.xml ]; then
echo "phpdoc-exists=true" >> $GITHUB_OUTPUT
else
echo "phpdoc-exists=false" >> $GITHUB_OUTPUT
fi
generate-phpdoc:
needs: [release, check-phpdoc]
runs-on: ubuntu-latest
container:
image: php:8.3
if: needs.check-phpdoc.outputs.phpdoc-exists == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- name: Download PHPDocumentor
run: |
wget https://phpdoc.org/phpDocumentor.phar
chmod +x phpDocumentor.phar
- name: Generate PHPDoc
run: |
php phpDocumentor.phar -d src -t docs
- name: Archive PHPDoc
run: |
zip -r docs.zip docs
- name: Upload PHPDoc
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs.zip
test:
needs: [release, debug, release-executable, debug-executable, release_executable, debug_executable, check-phpunit]
runs-on: ubuntu-latest
container:
image: php:8.3
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release
path: release
- name: Install dependencies
run: |
apt update -yqq
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
install-php-extensions zip
- name: Install phive
run: |
wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
- name: Install phab
run: |
phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
- name: Install latest version of NCC
run: |
git clone https://git.n64.cc/nosial/ncc.git
cd ncc
make redist
NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
php "$NCC_DIR/INSTALL" --auto
cd .. && rm -rf ncc
- name: Install NCC packages
run: |
ncc package install --package="release/net.nosial.configlib.ncc" --build-source --reinstall -y --log-level debug
- name: Run PHPUnit tests
run: |
wget https://phar.phpunit.de/phpunit-11.3.phar
php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt
- name: Upload test reports
uses: actions/upload-artifact@v4
with:
name: reports
path: reports
release-documentation:
needs: generate-phpdoc
permissions: write-all
runs-on: ubuntu-latest
container:
image: php:8.3
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download documentation artifact
uses: actions/download-artifact@v4
with:
name: documentation
path: documentation
- name: Upload documentation artifact
uses: softprops/action-gh-release@v1
with:
files: |
documentation/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-artifacts:
needs: [release, debug, release-executable, debug-executable, release_executable, debug_executable]
permissions: write-all
runs-on: ubuntu-latest
container:
image: php:8.3
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download release artifact
uses: actions/download-artifact@v4
with:
name: release
path: release
- name: Upload release artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download debug artifact
uses: actions/download-artifact@v4
with:
name: debug
path: debug
- name: Upload debug artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
debug/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download release-executable artifact
uses: actions/download-artifact@v4
with:
name: release-executable
path: release-executable
- name: Upload release-executable artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
release-executable/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download debug-executable artifact
uses: actions/download-artifact@v4
with:
name: debug-executable
path: debug-executable
- name: Upload debug-executable artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
debug-executable/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download release_executable artifact
uses: actions/download-artifact@v4
with:
name: release_executable
path: release_executable
- name: Upload release_executable artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
release_executable/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download debug_executable artifact
uses: actions/download-artifact@v4
with:
name: debug_executable
path: debug_executable
- name: Upload debug_executable artifact to release
uses: softprops/action-gh-release@v1
with:
files: |
debug_executable/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
build/
/.idea/php-test-framework.xml
/.idea/gbrowser_project.xml
/.phpunit.result.cache
/reports

View file

@ -4,6 +4,9 @@ before_script:
# Install some stuff that the image doesn't come with
- apt update -yqq
- apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
- curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
- chmod +x /usr/local/bin/install-php-extensions
- install-php-extensions zip
# Install phive
- wget -O phive.phar https://phar.io/releases/phive.phar
@ -20,10 +23,17 @@ before_script:
- git clone https://git.n64.cc/nosial/ncc.git
- cd ncc
- make redist
- php build/src/INSTALL --auto --install-composer
- NCC_DIR=$(find build/ -type d -name "ncc_*" | head -n 1)
- |
if [ -z "$NCC_DIR" ]; then
echo "NCC build directory not found"
exit 1
fi
- php "$NCC_DIR/INSTALL" --auto --install-composer
- cd .. && rm -rf ncc
build:
stage: build
script:
- ncc build --config release --log-level debug
artifacts:
@ -31,6 +41,15 @@ build:
- build/
rules:
- if: $CI_COMMIT_BRANCH
test:
stage: test
script:
- ncc package install --package="build/release/net.nosial.configlib.ncc" --reinstall -y --log-level debug
- wget https://phar.phpunit.de/phpunit-11.3.phar
- php phpunit-11.3.phar --configuration phpunit.xml
rules:
- if: $CI_COMMIT_BRANCH
release:
stage: deploy

1
.idea/ConfigLib.iml generated
View file

@ -5,6 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/reports" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

3
.idea/php.xml generated
View file

@ -11,9 +11,10 @@
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="/var/ncc/packages/net.nosial.optslib=1.1.2" />
<path value="/var/ncc/packages/net.nosial.loglib2=1.0.2" />
<path value="/var/ncc/packages/com.symfony.yaml=v7.1.5" />
<path value="/var/ncc/packages/net.nosial.loglib=2.0.4" />
<path value="/var/ncc/packages/net.nosial.optslib=1.1.2" />
<path value="/var/ncc/packages/com.symfony.polyfill_mbstring=v1.31.0" />
<path value="/var/ncc/packages/com.symfony.polyfill_ctype=v1.31.0" />
<path value="/usr/share/ncc" />

View file

@ -5,7 +5,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.1.2] - Ongoing
## [1.1.7] - 2025-03-14
This update introduces minor changes
### Changed
- Updated remote references for dependencies
- Updated Library to use net.nosial.loglib2 instead of the now deprecated net.nosial.loglib
## [1.1.6] - 2025-01-07
This update introduces minor improvements
### Changed
- Changed properties to become typed properties
### Added
- Added a new constructor parameter called `path` which is an optional parameter that allows you to specify the path to
the configuration files directory. If not specified the library will proceed with resolving
the path to the configuration files directory using the default method. This will override
the `CONFIGLIB_PATH` environment variable if it is set.
## [1.1.5] - 2024-12-27
This update introduces minor improvements
@ -13,6 +36,32 @@ This update introduces minor improvements
- Add support for CONFIGLIB_PATH environment variable to specify the path to the configuration files directory
## [1.1.4] - 2024-10-29
This update introduces a minor bug fix
### Fixed
- Fixed regex pattern for configuration properties being considered invalid when they contain an underscore.
## [1.1.3] - 2024-10-13
This update introduces a new build system
## [1.1.2] - 2024-09-27
> This change has been reverted
This update fixes a critical bug where configuration files may not be found when using different user accounts,
especially when the configuration file is located in a directory that is not accessible by the user account running the
application. This was fixed by changing the way the configuration file path is resolved including by adding a setup
execution unit that will be executed post-installation to ensure that the configuration file is accessible by the user
account running the application.
## [1.1.1] - 2024-09-26
This update introduces a minor bug fix

View file

@ -1,20 +1,33 @@
# Variables
CONFIG ?= release
DEFAULT_CONFIGURATION ?= release
LOG_LEVEL = debug
OUTDIR = build/$(CONFIG)
PACKAGE = $(OUTDIR)/net.nosial.configlib.ncc
# Default Target
all: build
all: release debug release-executable debug-executable release_executable debug_executable
# Build Steps
build:
ncc build --config=$(CONFIG) --log-level $(LOG_LEVEL)
release:
ncc build --config=release --log-level $(LOG_LEVEL)
debug:
ncc build --config=debug --log-level $(LOG_LEVEL)
release-executable:
ncc build --config=release-executable --log-level $(LOG_LEVEL)
debug-executable:
ncc build --config=debug-executable --log-level $(LOG_LEVEL)
release_executable:
ncc build --config=release_executable --log-level $(LOG_LEVEL)
debug_executable:
ncc build --config=debug_executable --log-level $(LOG_LEVEL)
install:
ncc package install --package=$(PACKAGE) --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL)
install: release
ncc package install --package=build/release/net.nosial.configlib.ncc --skip-dependencies --build-source --reinstall -y --log-level $(LOG_LEVEL)
test: release
[ -f phpunit.xml ] || { echo "phpunit.xml not found"; exit 1; }
phpunit
clean:
rm -rf build
.PHONY: all build install clean
.PHONY: all install test clean release debug release-executable debug-executable release_executable debug_executable

View file

@ -9,10 +9,25 @@ be configured more easily by following the documented instructions on how to alt
could use a builtin editor to edit the configuration file manually.
## Community
This project and many others from Nosial are available on multiple publicly available and free git repositories at
- [n64](https://git.n64.cc/nosial/configlib)
- [GitHub](https://github.com/nosial/configlib)
- [Codeberg](https://codeberg.org/nosial/configlib)
Issues & Pull Requests are frequently checked and to be referenced accordingly in commits and changes, Nosial remains
dedicated to keep these repositories up to date when possible.
For questions & discussions see the public Telegram community at [@NosialDiscussions](https://t.me/NosialDiscussions).
We do encourage community support and discussions, please be respectful and follow the rules of the community.
## Table of contents
<!-- TOC -->
* [ConfigLib](#configlib)
* [Community](#community)
* [Table of contents](#table-of-contents)
* [Installation](#installation)
* [Compile from source](#compile-from-source)

24
main
View file

@ -1,6 +1,24 @@
<?php
require('ncc');
import('net.nosial.configlib', 'latest');
if (PHP_SAPI !== 'cli')
{
print('net.nosial.configlib must be run from the command line.' . PHP_EOL);
exit(1);
}
\ConfigLib\Program::main();
if(!isset($argv))
{
if(isset($_SERVER['argv']))
{
$argv = $_SERVER['argv'];
}
else
{
print('net.nosial.configlib failed to run, no $argv found.' . PHP_EOL);
exit(1);
}
}
require('ncc');
\ncc\Classes\Runtime::import('net.nosial.configlib', 'latest');
exit(\ConfigLib\Program::main($argv));

15
phpdoc.dist.xml Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor configVersion="3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.phpdoc.org" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd">
<paths>
<output>build/docs</output>
<cache>build/cache</cache>
</paths>
<version number="latest">
<api>
<source dsn=".">
<path>src/ConfigLib</path>
</source>
<default-package-name>ConfigLib</default-package-name>
</api>
</version>
</phpdocumentor>

View file

@ -5,6 +5,9 @@
"minimum_version": "8.0",
"maximum_version": "8.2"
},
"options": {
"create_symlink": true
},
"update_source": {
"source": "nosial/libs.config@n64",
"repository": {
@ -13,35 +16,21 @@
"host": "git.n64.cc",
"ssl": true
}
},
"options": {
"create_symlink": true
}
},
"execution_policies":[
{
"name": "main",
"runner": "php",
"execute": {
"target": "main",
"working_directory": "%CWD%",
"tty": true
}
}
],
"assembly": {
"name": "ConfigLib",
"package": "net.nosial.configlib",
"description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API",
"company": "Nosial",
"copyright": "Copyright (c) 2022-2023 Nosial",
"description": "ConfigLib is a library for reading and writing configuration files via the NCC Runtime API",
"version": "1.1.2",
"version": "1.1.7",
"uuid": "9347259e-8e4d-11ed-85a7-fd07cf28ef35"
},
"build": {
"source_path": "src",
"default_configuration": "release",
"main": "main",
"main": "main_policy",
"define_constants": {
"VERSION": "%ASSEMBLY.VERSION%"
},
@ -49,31 +38,26 @@
{
"name": "net.nosial.optslib",
"version": "latest",
"source_type": "remote",
"source": "nosial/libs.opts=latest@n64"
"source": "nosial/optslib=latest@github"
},
{
"name": "net.nosial.loglib",
"name": "net.nosial.loglib2",
"version": "latest",
"source_type": "remote",
"source": "nosial/libs.log=latest@n64"
"source": "nosial/loglib2=latest@github"
},
{
"name": "com.symfony.filesystem",
"version": "latest",
"source_type": "remote",
"source": "symfony/filesystem=latest@packagist"
},
{
"name": "com.symfony.yaml",
"version": "latest",
"source_type": "remote",
"source": "symfony/yaml=latest@packagist"
},
{
"name": "com.symfony.process",
"version": "latest",
"source_type": "remote",
"source": "symfony/process=latest@packagist"
}
],
@ -90,7 +74,68 @@
"define_constants": {
"DEBUG": "1"
}
},
{
"name": "release-executable",
"build_type": "executable",
"output": "build/release/release_executable_gz",
"options": {
"ncc_configuration": "release"
}
},
{
"name": "debug-executable",
"build_type": "executable",
"output": "build/debug/debug_executable_gz",
"options": {
"ncc_configuration": "debug"
}
},
{
"name": "release_executable",
"build_type": "executable",
"output": "build/release/%ASSEMBLY.NAME%",
"options": {
"ncc_configuration": "release"
}
},
{
"name": "debug_executable",
"build_type": "executable",
"output": "build/debug/%ASSEMBLY.NAME%",
"options": {
"ncc_configuration": "debug"
},
"define_constants": {
"DEBUG": "1"
}
}
]
},
"execution_policies": [
{
"name": "main",
"runner": "php",
"execute": {
"working_directory": "%CWD%",
"silent": false,
"tty": true,
"timeout": null,
"idle_timeout": null,
"target": "main"
}
},
{
"name": "main_policy",
"runner": "php",
"execute": {
"working_directory": "%CWD%",
"silent": false,
"tty": true,
"timeout": null,
"idle_timeout": null,
"target": "main"
}
}
]
}

14
setup Normal file
View file

@ -0,0 +1,14 @@
<?php
$global_directory = $path = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'configlib';
//try creating the directory if it doesn't exist
if(!file_exists($global_directory))
{
if(!mkdir($global_directory, 0777, true))
{
exit('Failed to create global directory');
}
chmod($global_directory, 0777);
}

View file

@ -1,11 +1,9 @@
<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace ConfigLib;
use Exception;
use LogLib\Log;
use LogLib2\Logger;
use RuntimeException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
@ -13,45 +11,51 @@
class Configuration
{
/**
* The name of the configuration
*
* @var string
* The logger of the class
* @var Logger
*/
private $name;
private Logger $logger;
/**
* The name of the configuration
* @var string|array
*/
private string|array $name;
/**
* The path to the configuration file
*
* @var string
* @var string|null
*/
private $path;
private ?string $path;
/**
* The configuration data
*
* @var array
*/
private $configuration;
private array $configuration;
/**
* Indicates if the current instance is modified
*
* @var bool
*/
private $modified;
private bool $modified;
/**
* Public Constructor
*
* @param string $name The name of the configuration (e.g. "MyApp" or "net.example.myapp")
* @param string|null $path The directory where the configuration file will be stored
*/
public function __construct(string $name='default')
public function __construct(string $name='default', ?string $path=null)
{
$this->logger = new Logger('net.nosial.configlib');
// Sanitize $name for a file path
$name = strtolower($name);
$name = str_replace(array('/', '\\', '.'), '_', $name);
$env = getenv(sprintf("CONFIGLIB_%s", strtoupper($name)));
$this->path = null;
if($env !== false)
{
if(file_exists($env))
@ -60,12 +64,29 @@
}
else
{
Log::warning('net.nosial.configlib', sprintf('Environment variable "%s" points to a non-existent file, resorting to default/builtin configuration', $env));
$this->logger->warning(sprintf('Environment variable "%s" points to a non-existent file, resorting to default/builtin configuration', $env));
}
}
if($path !== null)
{
if(!is_dir(dirname($path)))
{
throw new RuntimeException(sprintf('Directory "%s" does not exist', dirname($path)));
}
if(!is_writable(dirname($path)))
{
throw new RuntimeException(sprintf('Directory "%s" is not writable', dirname($path)));
}
$this->path = $path;
}
if ($this->path === null)
{
$filePath = $name . '.conf';
// If the CONFIGLIB_PATH environment variable is set, use it as the configuration path
if(getenv('CONFIGLIB_PATH'))
{
@ -73,7 +94,6 @@
}
else
{
$filePath = $name . '.conf';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
$configDir = getenv('APPDATA') ?: getenv('LOCALAPPDATA');
@ -119,7 +139,7 @@
if (!$configDir)
{
Log::warning('net.nosial.configlib', sprintf('Unable to find a proper directory to store configuration paths in, using temporary directory instead: %s', sys_get_temp_dir()));
$this->logger->warning(sprintf('Unable to find a proper directory to store configuration paths in, using temporary directory instead: %s', sys_get_temp_dir()));
$configDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'configlib';
}
}
@ -151,7 +171,7 @@
}
catch(Exception $e)
{
Log::error('net.nosial.configlib', sprintf('Unable to load configuration "%s", %s', $this->name, $e->getMessage()));
$this->logger->error(sprintf('Unable to load configuration "%s", %s', $this->name, $e->getMessage()), $e);
throw new RuntimeException(sprintf('Unable to load configuration "%s"', $this->name), $e);
}
}
@ -169,7 +189,7 @@
*/
private static function validateKey(string $input): bool
{
if (preg_match('/^([a-zA-Z0-9_]+\.?)+$/', $input))
if (preg_match('/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$/', $input))
{
return true;
}
@ -343,7 +363,7 @@
}
$this->modified = false;
Log::debug('net.nosial.configlib', sprintf('Configuration "%s" saved', $this->name));
$this->logger->debug(sprintf('Configuration "%s" saved', $this->name));
}
/**
@ -425,7 +445,7 @@
}
$this->modified = false;
Log::debug('net.nosial.configlib', 'Loaded configuration file: ' . $this->path);
$this->logger->debug('Loaded configuration file: ' . $this->path);
}
/**
@ -483,7 +503,7 @@
}
catch(Exception $e)
{
Log::error('net.nosial.configlib', sprintf('Unable to save configuration "%s" to disk, %s', $this->name, $e->getMessage()));
$this->logger->error(sprintf('Unable to save configuration "%s" to disk, %s', $this->name, $e->getMessage()), $e);
}
}
}

View file

@ -9,8 +9,12 @@ class ConfigurationTest extends TestCase
public static function setUpBeforeClass(): void
{
$config = new Configuration('test');
if(file_exists($config->getPath()))
{
unlink($config->getPath());
}
}
public function testConstruct(): void
{
@ -24,6 +28,7 @@ class ConfigurationTest extends TestCase
$this->assertTrue($config->set('key1.key2', 'value', true));
$this->assertEquals('value', $config->get('key1.key2'));
}
public function testSetNotExists(): void