Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/multitheftauto/mtasa-php-sdk
The official PHP SDK for the Multi Theft Auto Web Interface.
https://github.com/multitheftauto/mtasa-php-sdk
composer httplug multi-theft-auto php sdk
Last synced: 2 days ago
JSON representation
The official PHP SDK for the Multi Theft Auto Web Interface.
- Host: GitHub
- URL: https://github.com/multitheftauto/mtasa-php-sdk
- Owner: multitheftauto
- License: mit
- Created: 2019-01-10T08:40:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-01T11:29:37.000Z (over 1 year ago)
- Last Synced: 2024-04-14T05:11:58.830Z (7 months ago)
- Topics: composer, httplug, multi-theft-auto, php, sdk
- Language: PHP
- Homepage: https://multitheftauto.com
- Size: 406 KB
- Stars: 19
- Watchers: 6
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# MTA:SA PHP SDK
![PHP Composer](https://github.com/multitheftauto/mtasa-php-sdk/workflows/PHP%20Composer/badge.svg?branch=master)You can access the MTA Web Interface from almost any programming language that can request web pages. PHP can do this very easily.
This SDK provides one function call that will allow you to call any exported script functions on any server that you have access to.
See the [official wiki page](https://wiki.multitheftauto.com/wiki/PHP_SDK) for further information.
## Installation
### Prerequisites
This SDK requires PHP 7.4 or greater.
### HTTPlug client abstraction
As this SDK uses HTTPlug, you will have to require some libraries for get it working. See ["HTTPlug for library users"](http://docs.php-http.org/en/latest/httplug/users.html) for more info.
**Quick installation (Fixed from HTTPlug documentation)**
```
composer require php-http/curl-client guzzlehttp/psr7 php-http/message http-interop/http-factory-guzzle
```:warning: **Note**: If you don't follow this requirement before require the SDK, composer will throw you an error.
### Setup
The only supported installation method is via [Composer](https://getcomposer.org). Run the following command to require this SDK in your project:
```
composer require multitheftauto/mtasa-php-sdk
```## A simple example
There are three ways to call an MTA server's exported functions, as shown in the following example:
```php
getResource('someResource')->call('callableFunction', $arg1, $arg2, $arg3, ...);
// or
$response = $mta->getResource('someResource')->call->callableFunction($arg1, $arg2, $arg3, ...);var_dump($response);
```# Development environment setup
**Prerequisites**:
- [docker-compose](https://docs.docker.com/compose/install/)First, we need to build the local docker image. To do this, run the following command:
$ docker-compose build
We will be using an alias for executing the development commands.
$ alias dcli='docker-compose -f docker-compose.cli.yml run --rm'
**Install dependencies**:
$ dcli composer install
## Running tests
To run the project tests and validate the coding standards:
$ dcli composer test
To run all unit tests you can use:
$ dcli phpunit
To run specific unit test you can use --filter option:
$ dcli phpunit --filter=ClassName::MethodName