Download the PHP package wyz/practicalafas without Composer

On this page you can find all versions of the php package wyz/practicalafas. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package practicalafas

PracticalAFAS Build Status

A PHP library for communicating with AFAS Profit in a practical way, using either SOAP or REST.

Introduction

This is library code, for use by your own code/another project. Whoever is reading this, supposedly already has an idea of what they want to achieve and what AFAS is, so we won't address that here. (http://www.afas.nl/ - their current documentation is at https://static-kb.afas.nl/datafiles/help/2_9_7/SE/EN/index.htm though that URL will undoubtedly change.)

This code formed through three principles:

The first (and third) principle means understandable code is preferred over future-proof extensibility that creates separate classes for each little thing and introduces loads of boiler plate code. It means well commented code. And it means no unexpected / undocumented behavior. (The validation of input arguments, and of results received from the remote system, covers situations which are unexpected for the programmer, and throws documented exceptions.)

That said: the second / third principle, plus evolving AFAS functionality plus backward compatibility considerations, have made the Connection::getData() arguments illogical in some aspects. But the code is still fairly easily readable (because there's not many different methods) and easy to call for 'simple' use cases.

Compatibility

Version 2 of the library works with PHP5 (5.4 and up) and PHP7.

Client classes for REST and SOAP use PHP's standard Curl + JSON and SOAP + SimpleXML extensions; if these do not work for you, PRs with new / modified clients are welcome.

Automatic testing is done on PHP5.6, 7.1 and 7.2 for the UpdateConnector classes. (I currently don't consider the Client classes in need of tests. There may be some light tests for Connection in the future but it's not on my list.)

Although PHP5.6 is not officially supported anymore, this library will remain compatible with it until there is a real reason to introduce PHP7-only language constructs.

Using the classes

There are a few parts of this library which are not all tightly coupled:

We'll first discuss the clients and give call examples for comparison purposes with the Connection. You can skip these, unless you're curious about the differences.

Client classes

These could be used standalone to make SOAP / REST calls to AFAS Profit, if you know the structure of the calls. A client class only deals with:

The connection and authentication settings get passed into the constructor; not to every individual AFAS call.

You will only use one public method: callAfas(). (There is a second public method: static getClientType() - but this is not necessary for standalone use.) Client classes make (almost) no assumptions about the remote API calls; the exact (type of) remote method and arguments need to be passed to it, and it will return the result body as a string.

RestCurlClient examples

The required options are in the constructor below; see the code for other options.

SoapAppClient examples

The below is (almost) equivalent to the above REST example (except it returns an XML string instead of a JSON string). Note that this is not a PHP 'Soapclient' class; it's a wrapper around SOAPClient.

Connection

The Connection wraps around a Client and abstracts away all argument validation / data processing that is not client specific. It has a.o. its own syntax for filters. It has two important methods: sendData() which wraps AFAS' Update connector, and getData() which wraps all other connectors. (All other methods are getters and setters that you might never need.)

The equivalent to the above example is:

...so if the 'Outputmode' option is not provided, getData() returns an array of data rows instead (i.e. the XML/JSON string gets decoded for you).

Further reading

Get connectors

Update connectors / UpdateObject classes

Hints for developers

Authors

I like contributing open source software to the world and I like opening up semi-closed underdocumented systems. (Which was the case with AFAS in 2012, but it has gotten better.) Give me a shout-out if this is useful or if you have a contribution. Contact me if you need integration work done. (I have experience with several other systems.)

License

This library is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments


All versions of practicalafas with dependencies

PHP Build Version
Package Version
Requires ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wyz/practicalafas contains the following files

Loading the files please wait ....