https://github.com/tmilos/scim-schema
SCIM schema PHP library
https://github.com/tmilos/scim-schema
php scim scim-2 scim-schema
Last synced: 9 months ago
JSON representation
SCIM schema PHP library
- Host: GitHub
- URL: https://github.com/tmilos/scim-schema
- Owner: tmilos
- License: mit
- Created: 2017-01-24T14:49:02.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T16:07:43.000Z (about 2 years ago)
- Last Synced: 2024-10-19T09:04:22.921Z (about 1 year ago)
- Topics: php, scim, scim-2, scim-schema
- Language: PHP
- Size: 90.8 KB
- Stars: 14
- Watchers: 3
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scim Schema
SCIM schema PHP library with support for both v1 and v2.
> **Note:** This library is still work in progress, and you are welcome to help and contribute
> It was made by the specs from [SimpleCloud](http://www.simplecloud.info/) and by the example documents generated by
[PowerDMS/Owin.Scim](https://github.com/PowerDMS/Owin.Scim)
> Do not miss [SCIM Filter Parser](https://github.com/tmilos/scim-filter-parser) !
[](https://twitter.com/tmilos77)
[](https://travis-ci.org/tmilos/scim-schema)
[](https://coveralls.io/github/tmilos/scim-schema?branch=master)
[](https://scrutinizer-ci.com/g/tmilos/scim-schema)
[](https://packagist.org/packages/tmilos/scim-schema)
[](https://packagist.org/packages/tmilos/scim-schema)
# Install
Install Scim Schema using composer:
```bash
composer require tmilos/scim-schema
```
# Usage
### Schema
Build default schema:
```php
$schemaBuilder = new SchemaBuilderV2(); // or SchemaBuilderV1
$groupSchema = $schemaBuilder->getGroup();
$userSchema = $schemaBuilder->getUser();
$enterpriseUserSchema = $schemaBuilder->getEnterpriseUser();
$schemaSchema = $schemaBuilder->getSchema();
$serviceProviderConfigSchema = $schemaBuilder->getServiceProviderConfig();
$resourceTypeSchema = $schemaBuilder->getResourceType();
```
Or build your own custom schema:
```php
$schema = new Schema();
$schema->setName('CustomSchema');
$schema->addAttribute(
AttributeBuilder::create('name', ScimConstants::ATTRIBUTE_TYPE_STRING, 'Name of the object')
->setMutability(false)
->getAttribute()
);
```
And serialize the scim schema object
```php
$schema = (new SchemaBuilderV2())->getUser();
$schema->serializeObject();
```
### Schema validation
An object can be validated against a schema:
```php
/** @var array $object */
$object = getTheObjectAsArray();
$validator = new SchemaValidator();
$objectSchema = getTheSchema();
$schemaExtensions = getSchemaExtensions();
$validationResult = $validator->validate(
$object,
$objectSchema,
$schemaExtensions
);
if (!$validationResult->getErrors()) {
// cool!
} else {
print implode("\n", $validationResult->getErrorsAsStrings());
}
```