ltb-project / ltb-common
PHP framework for LTB project applications
Requires
- php: >=7.4
- ext-ldap: >=7.4
- bjeavons/zxcvbn-php: ^1.0
- mxrxdxn/pwned-passwords: ^v2.1.0
- phpmailer/phpmailer: ^6.5.0
- predis/predis: ^v2.2.2
- symfony/cache: ^v5.4.42
Requires (Dev)
- mockery/mockery: >=1.4
- phpunit/phpunit: >=8
- dev-main
- v0.4.0
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.0
- v0.1.0-alpha
- v0.0.3-alpha
- v0.0.2-beta
- v0.0.2-alpha
- v0.0.1-beta
- dev-56-add-methods-to-get-start-and-end-date
- dev-match_dn_filter_base
- dev-44-openldap-account-disabling
- dev-36-add-password-policy
- dev-40-improve-cache-modularity
- dev-37-create-cache-functions
- dev-22-scope-in-search-function
- dev-25-rename-project
- dev-23-add-get_first_value
- dev-14-restore-default-values-in-modify_attributes_using_ppolicy
- dev-4-do-not-use-global-vars
This package is auto-updated.
Last update: 2024-12-27 13:44:27 UTC
README
Presentation
This is a PHP library to share code between LTB applications like Self Service Password, White Pages, Service Desk, ...
Installation
Add the dependency in your composer configuration:
{ "require": { "ltb-project/ltb-common": "v0.2.1" } }
Then update dependencies:
composer update
Use autoloading in your code to load composer dependencies:
require __DIR__ . 'vendor/autoload.php';
Usage
LDAP connection
$ldap_url = "ldap://ldap.example.com"; $ldap_starttls = false; $ldap_binddn = "cn=admin,dc=example,dc=com"; $ldap_bindpw = "secret"; $ldap_network_timeout = 3; $ldap_user_base = "ou=people,dc=example,dc=com"; $ldap_size_limit = -1; $ldap_krb5ccname = null; $ldap_page_size = 1000; $ldapInstance = new \Ltb\Ldap( $ldap_url, $ldap_starttls, $ldap_binddn, $ldap_bindpw, $ldap_network_timeout, $ldap_user_base, $ldap_size_limit, $ldap_krb5ccname, $ldap_page_size ); $ldap_connection = $ldapInstance->connect(); $ldap = $ldap_connection[0]; $result = $ldap_connection[1]; if (!$result) { error_log("Unable to connect to $ldap_url"); exit 1; }
Tests
Unit tests
Get composer dependencies:
composer update
Run the tests:
vendor/bin/phpunit tests/Ltb
If you want coverage analysis, make sure to install xdebug
PHP extension, and run:
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --configuration phpunit.xml
Integration tests
Make sure you have docker or podman installed
Get composer dependencies:
composer update
Run the tests (requires an internet connection for donwloading the openldap docker image):
./runIntegrationTests.sh
If you already have an openldap server, you can also adapt the tests in tests/ directory, and run them with:
vendor/bin/phpunit tests/IntegrationTests