elielelie/laravel-sap

SAP features integrated with Laravel.
1,370 1
Install
composer require elielelie/laravel-sap
Latest Version:v1.0.7
PHP:^8.2
License:MIT
Last Updated:Mar 4, 2026
Links: GitHub  ·  Packagist
Maintainer: elielelie

Laravel SAP Driver

SAP features integrated with Laravel.

Maintainer PHP VERSION BUILD LICENSE

Installation

Make sure you have the php7-sapnwrfc extension installed.

composer require elielelie/laravel-sap

To establish the connection with SAP, you need to add the following variables to your .env file:

SAP_HOST        Host
SAP_SYSTEM      System number
SAP_LANGUAGE    Language default
SAP_CLIENT      Client instance
SAP_USERNAME    Username
SAP_PASSWORD    Password    

You can publish the configuration file and add new connections by running:

$ php artisan vendor:publish --provider="Elielelie\Sap\SapServiceProvider"

Usage

Connecting to SAP

<?php

use Elielelie\Sap\Sap;

$sap = app(Sap::class);

$connection = $sap->open();

or

// Connection name defined in the configuration file config/sap.php
 
$connection = $sap->open('name');

Perform Function Module call

<?php

// ... connection

$function = $connection->fm('BAPI_USER_GET_DETAIL');

// Get function description.
print_r($function->description());

// Add import parameter.
$function->param('USERNAME', 'USER');

// Perform function call and retrieve result.
$results = $function->execute();

$connection->close();

Getting details about a user using RFC_READ_TABLE

<?php

// ... connection

$function = $connection->fm('RFC_READ_TABLE');

$function->param('QUERY_TABLE', 'USR01')
	->param('OPTIONS', [
		['TEXT' => 'BNAME = 'USER' OR BNAME = 'USER2' OR BNAME LIKE 'USER5*']
	])
	->param('ROWCOUNT', 5)
	->param('DELIMITER', '~')
;

$result = $function->execute();

$connection->close();

Query Builder usage

<?php

// ... connection

$fm = $connection->fmc(Table::class);

$results = $fm->table('USR01')
    ->fields(['BNAME', 'STCOD', 'MANDT' ...])
	->where('bname', ['USER', 'USER5'])
	->orWhere('bname', 'LIKE', 'USER5*')
	->limit(5)
	->get()
;

Testing

This package includes a comprehensive test suite using Pest PHP.

Running Tests

# Run all tests
php vendor/bin/pest

# Run with detailed output
php vendor/bin/pest --testdox

# Run with coverage
php vendor/bin/pest --coverage

Test Coverage

  • Unit Tests: Guid, Arr, QueryBuilder, Server (100% coverage)
  • ⏭️ Feature Tests: Connection, Sap, FunctionModule, Table (require SAP connection or mocking)

For more information about testing, see TESTING.md.

License

This software is licensed under the MIT license. See LICENSE for details.

Legal Notice

SAP and other SAP products and services mentioned herein are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries.

Related Packages

ntanduy/cloudflare-d1-database

Cloudflare D1 database driver for Laravel — full Eloquent & Query Builder suppor...

9,202 28
elielelie/laravel-activemq

Laravel ActiveMQ driver

4,509 0
babenkoivan/elastic-scout-driver

Elasticsearch driver for Laravel Scout

4,512,458 275
babenkoivan/elastic-scout-driver-plus

Extension for Elastic Scout Driver

3,389,168 286
asseco-voice/laravel-stomp

Laravel Stomp driver

8,283 5