Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ltb-project/ltb-common
PHP framework for LTB project applications
https://github.com/ltb-project/ltb-common
composer ldap php
Last synced: about 2 months ago
JSON representation
PHP framework for LTB project applications
- Host: GitHub
- URL: https://github.com/ltb-project/ltb-common
- Owner: ltb-project
- License: gpl-3.0
- Created: 2023-01-03T07:28:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T14:25:19.000Z (2 months ago)
- Last Synced: 2024-10-29T17:34:29.589Z (2 months ago)
- Topics: composer, ldap, php
- Language: PHP
- Homepage: https://packagist.org/packages/ltb-project/ldap
- Size: 114 KB
- Stars: 3
- Watchers: 8
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LDAP Tool Box PHP framework
[![Latest Stable Version](https://poser.pugx.org/ltb-project/ltb-common/v)](https://packagist.org/packages/ltb-project/ltb-common)
[![Latest Unstable Version](https://poser.pugx.org/ltb-project/ltb-common/v/unstable)](https://packagist.org/packages/ltb-project/ltb-common)
[![Total Downloads](https://poser.pugx.org/ltb-project/ltb-common/downloads)](https://packagist.org/packages/ltb-project/ltb-common)
[![CI Status](https://github.com/ltb-project/ltb-common/actions/workflows/unittests.yml/badge.svg)](https://github.com/ltb-project/ltb-common/actions/workflows/unittests.yml)
[![Composer Status](https://github.com/ltb-project/ltb-common/actions/workflows/php.yml/badge.svg)](https://github.com/ltb-project/ltb-common/actions/workflows/php.yml)## Presentation
This is a PHP library to share code between LTB applications like [Self Service Password](https://github.com/ltb-project/self-service-password), [White Pages](https://github.com/ltb-project/white-pages), [Service Desk](https://github.com/ltb-project/service-desk), ...
## Installation
Add the dependency in your [composer](https://getcomposer.org/) configuration:
```json
{
"require": {
"ltb-project/ltb-common": "v0.2.1"
}
}
```Then update dependencies:
```
composer update
```Use autoloading in your code to load composer dependencies:
```php
require __DIR__ . 'vendor/autoload.php';
```## Usage
### LDAP connection
```php
$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
```