PHPackages                             we-simply-code/laravel-afas-rest-connector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. we-simply-code/laravel-afas-rest-connector

ActiveLibrary

we-simply-code/laravel-afas-rest-connector
==========================================

This package integrates the AFAS REST API with Laravel

1.3.8(6mo ago)951.1k↓73.8%11MITPHPPHP ^7.3|^8.0|^8.1|^8.2

Since Mar 7Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/wesimplycode/laravel-afas-rest-connector)[ Packagist](https://packagist.org/packages/we-simply-code/laravel-afas-rest-connector)[ RSS](/packages/we-simply-code-laravel-afas-rest-connector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (32)Used By (0)

What this package does
----------------------

[](#what-this-package-does)

This package integrates the AFAS REST API with Laravel with a minimal setup.

[![Latest Version on Packagist](https://camo.githubusercontent.com/125ea51422d2f6aad75ee0fb026787e9b3cf7a08b85ae08b472476f6c6aa2a10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77652d73696d706c792d636f64652f6c61726176656c2d616661732d726573742d636f6e6e6563746f72)](https://packagist.org/packages/we-simply-code/laravel-afas-rest-connector)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [GetConnector](#getconnector)
        - [Filters](#filters)
            - [Take](#take)
            - [Skip](#skip)
            - [SortOnField](#sortonfield)
            - [Where](#where)
            - [orWhere](#orwhere)
            - [Execute](#execute)
            - [Inspecting the where filter](#inspecting-the-where-filter)
    - [UpdateConnector](#updateconnector)
        - [Insert &amp; Update records](#insert--update-records)
    - [Generating URL](#generating-url)
    - [Meta info](#metainfo)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

```
composer require we-simply-code/laravel-afas-rest-connector

```

After installation publish the config file

```
php artisan vendor:publish --provider="WeSimplyCode\LaravelAfasRestConnector\LaravelAfasRestConnectorServiceProvider"

```

In the config file you can add different connections to the AFAS profitServices. One connection is added by default. If you will be using only one connection use the default connection. If you will be using multiple connections use the default connection for the connection you will be using the most to make things easier.

#### For each connection in the config file you will have to add the connectors. Each connection contains the getConnectors &amp; updateConnectors array.

[](#for-each-connection-in-the-config-file-you-will-have-to-add-the-connectors-each-connection-contains-the-getconnectors--updateconnectors-array)

#### Add your connectors to these arrays. The key can be anything you want (you will use this as the name of the connector in your code), the value has to be the id of the connector in AFAS profitService.

[](#add-your-connectors-to-these-arrays-the-key-can-be-anything-you-want-you-will-use-this-as-the-name-of-the-connector-in-your-code-the-value-has-to-be-the-id-of-the-connector-in-afas-profitservice)

Add the following variables to your .env file

```
AFAS_ENVIRONMENT="Your AFAS environment # here" //example: T11111AA
AFAS_TOKEN="Your AFAS token here" // example: 1tokendata
```

Usage
-----

[](#usage)

I assume you know how the AFAS profitServices work and what the different connectors do. If not please take a look at the documentation for the AFAS REST API: [https://help.afas.nl/help/EN/SE/App\_Cnr\_Rest\_Api.htm?query=rest](https://help.afas.nl/help/EN/SE/App_Cnr_Rest_Api.htm?query=rest)

This package ships with a facade to access the different connectors easily. After retrieving your connector you can apply filters to it or add data to it and then call the `execute()` method to make the call to AFAS profitServices.

#### GetConnector

[](#getconnector)

With the GetConnector you can retrieve data from AFAS profitService. The getConnector supports the simple filter, or the json filter. After configuring your getConnectors for your connection you can use the like this:

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will give you the "contacts" getConnector for the default connection
Afas::getConnector('contacts');

// This will give you the "contacts" getConnector for a different connection
Afas::getConnector('contacts', 'differentConnectionName');
```

#### Filters

[](#filters)

You can apply filters on getConnectors to retrieve more specific data. There is no specific order to apply filters. You can chain as many filters as you want except for the `take()` and `skip()` filter. Those can only be used once per request. **By default, this package will use the simple filter to retrieve results. You can enable the jsonFilter when your queries get a bit more advanced.**Check out the official documentation about the differences between the simple filter and the jsonFilter: [https://help.afas.nl/help/EN/SE/App\_Cnr\_Rest\_GET.htm#o85263](https://help.afas.nl/help/EN/SE/App_Cnr_Rest_GET.htm#o85263)

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will give you a getConnector instance with the simple filter enabled
Afas::getConnector('contacts');

// This will give you a getConnector instance with the json filter enabled
Afas::getConnector('contacts', true);
```

###### Take

[](#take)

By default, the profitServices return 100 results. You can adjust the amount of results by adding the `take()` filter.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will add the take filter to the connector with an amount of 10
Afas::getConnector('contacts')->take(10);
```

###### Skip

[](#skip)

You can skip results by adding the `skip()` filter.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will add the skip filter to the connector with an amount of 10
Afas::getConnector('contacts')->skip(10);
```

###### SortOnField

[](#sortonfield)

Sort the results on any field. By default, the results will be ascending but with and extra parameter you can change that. Field names must be exact the same as they are in AFAS profitServices.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will sort the results ascending by the field 'Name'
Afas::getConnector('contacts')->sortOnField('Name');

// Add true as second parameter to sort the results descending
// This will sort the results descending by the field 'Name'
Afas::getConnector('contacts')->sortOnField('Name', true);
```

###### Where

[](#where)

If you want to get specific results from the getConnector you can use the `where()` filter (records must match all criterion). It is recommended to always use the `where()`filter with the getConnector as it enhances the performance and only gives you the results you need.

All AFAS Profit filters for the `where()` filter are available. The filters are listed in the config file. You can use them in their symbol form, or their text form.

**By default, the getConnector uses the simple filter. To enable the jsonFilter you can pass `true` as second parameter to the getConnector.**

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// The where() filter accepts the field type as first parameter, filter type as second and what the results should be filtered on as third
// Get only the contacts of type Person (simple filter)
Afas::getConnector('contacts')->where('type', '=', 'Person');

// Get only the contacts of type Person (json filter)
Afas::getConnector('contacts', true)->where('type', '=', 'Person');

// You can chain as much where filters as needed
// Get only the contacts from the Netherlands who are organizations
Afas::getConnector('contacts')
    ->where('country', '=', 'Netherlands')
    ->where('type', '=', 'Organization');
```

###### orWhere

[](#orwhere)

You can use the `orWhere()` filter to add another where clause to the filter (records must match at least one criterion). Please check out the official docs how this works.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// The orWhere() filter accepts the field type as first parameter, filter type as second and what the results should be filtered on as third
// Get the contacts of type Person or Organization
Afas::getConnector('contacts')
    ->where('type', '=', 'Person')
    ->orWhere('type', '=', 'Organization');

// Get only the contacts from the Netherlands or Germany who are organizations (json filter)
Afas::getConnector('contacts', true)
    ->where('type', '=', 'Organization')
    ->where('country', '=', 'Netherlands')
    ->orWhere('type', '=', 'organization')
    ->where('country', '=', 'Germany');
```

**Sometimes the simple filter isn't enough to query specific results. Enable the jsonFilter when doing advanced queries. The jsonFilter and the simple filter don't always return the same results!**

#### Execute

[](#execute)

The `execute()` method is used when you have configured the connector accordingly to make the call to the AFAS profitServices.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// Execute the call. This will retrieve 100 contacts from the AFAS profitServices
Afas::getConnector('contacts')->execute();

// Retrieve 10 contacts
Afas::getConnector('contacts')
    ->take(10)
    ->execute();

// Retrieve 100 contacts but skip the first
Afas::getConnector('contacts')
    ->skip(1)
    ->execute();

// Retrieve 10 contacts and skip the first
Afas::getConnector('contacts')
    ->skip(1)
    ->take(10)
    ->execute();
```

This package uses Laravel's wrapper around Guzzle to make http calls. That means that after we call the `execute()` method, we can use the methods Laravel provides to inspect the response. Example:

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will return the request status
Afas::getConnector('contacts')
    ->execute()
    ->status();

// This will return the response in JSON
Afas::getConnector('contacts')
    ->execute()
    ->json();
```

Check out the documentation for the Laravel http client:

#### Inspecting the where filter

[](#inspecting-the-where-filter)

If you want to inspect the json from the where filter you can call the `getJsonFilter()` method instead of the `execute()` method after configuring the getConnector.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// This will return the where filter in a json string
Afas::getConnector('contacts')
    ->take(10)
    ->where('Type', '=', 'Person')
    ->getJsonFilter();
```

This method won't return the take, skip and sortOnField filter.

#### UpdateConnector

[](#updateconnector)

With the UpdateConnector you can insert, update or delete records from AFAS profitService. You can use a tool like  to inspect the json object required to manipulate data in AFAS profitService, or you can call the `metaInfo()` method on the connector to inspect the fields.

#### Insert &amp; Update records

[](#insert--update-records)

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

$data = [
            "KnPerson" => [
                "Element" => [
                    "Fields" => [],
                ],
            ],
        ];
// Create a new record in AFAS profitService
Afas::updateConnector('person')->insert($data);

// Update an existing record in AFAS profitService
Afas::updateConnector('person')->update($data);
```

#### Generating URL

[](#generating-url)

If you want to inspect the URL that is being generated by the connector you can call the `getUrl()`method instead of the `execute()` method after configuring the connector.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// Both of these will return the generated URL by the connector (you can use this directly to make a call in something like Postman)
Afas::getConnector('contacts')->getUrl();

Afas::getConnector('contacts')
    ->take(10)
    ->where('Type', '=', 'Person')
    ->getUrl();
```

#### MetaInfo

[](#metainfo)

To inspect the meta info about a connector we can simply call the `metaInfo()` method.

```
use WeSimplyCode\LaravelAfasRestConnector\Facades\Afas;

// Get the meta info from the connector
Afas::getConnector('contacts')->metaInfo();
Afas::updateConnector('person')->metaInfo();

// Get the json representation of the meta info from the connector
Afas::getConnector('contacts')->metaInfo()->json();
Afas::updateConnector('person')->metaInfo()->json();
```

Credits
-------

[](#credits)

Sunil Kisoensingh

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance69

Regular maintenance activity

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~57 days

Recently: every ~152 days

Total

31

Last Release

180d ago

PHP version history (3 changes)1.0.0PHP ^7.3|^8.0

1.3.3PHP ^7.3|^8.0|^8.1

1.3.6PHP ^7.3|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1b3ce44372eaf2cc42e580b600bcd32b58539d64716c6ad4196dcae24025b96?d=identicon)[sun1l](/maintainers/sun1l)

---

Top Contributors

[![sunilvrk](https://avatars.githubusercontent.com/u/25526594?v=4)](https://github.com/sunilvrk "sunilvrk (90 commits)")[![ixp-nl](https://avatars.githubusercontent.com/u/7010978?v=4)](https://github.com/ixp-nl "ixp-nl (1 commits)")[![jeffreyvr](https://avatars.githubusercontent.com/u/9550079?v=4)](https://github.com/jeffreyvr "jeffreyvr (1 commits)")[![KalimeroMK](https://avatars.githubusercontent.com/u/24772657?v=4)](https://github.com/KalimeroMK "KalimeroMK (1 commits)")[![siebsie23](https://avatars.githubusercontent.com/u/25083973?v=4)](https://github.com/siebsie23 "siebsie23 (1 commits)")[![wijzijnweb](https://avatars.githubusercontent.com/u/79093089?v=4)](https://github.com/wijzijnweb "wijzijnweb (1 commits)")

### Embed Badge

![Health badge](/badges/we-simply-code-laravel-afas-rest-connector/health.svg)

```
[![Health](https://phpackages.com/badges/we-simply-code-laravel-afas-rest-connector/health.svg)](https://phpackages.com/packages/we-simply-code-laravel-afas-rest-connector)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
