Giter Club home page Giter Club logo

api-client-php's People

Contributors

bheisig avatar i-doitadmin avatar leonardfischer avatar okt90 avatar pklinkov avatar pta42 avatar rakoitde avatar skekec1 avatar tschreiner avatar yhildebrandt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

api-client-php's Issues

Fehler "i-doit-api-client-php"-Initialisierung

Guten Tag

Ich habe eine neue Installation von i-doit in der Version 1.15.1 PRO und die API in der Version 1.11.2. Für diverse Tests möchte ich den API-Client nutzen. Die Nutzung des Clients erfolgt über "xampp". Bei dem Befehl "Initialize.php" erfolgt die Abfrage für den APi entry-point und den APi-Key. Danach erhalte ich folgende Fehlermeldung;

image

Ich habe auch eine Testinstallation unter i-doit Version 1.15.2 und der API Version 1.11.3, erhalte aber die gleiche Fehlermeldung.

Herzlichen Dank für Eure Hilfestellung.

Christian

kann beim kategorieeintrag fuer 'version' erstellen das feld 'patchlevel' nicht setzen

Expected behavior

   $entryID = $category->create(
        $jdkID,
        'C__CATG__VERSION',
        [
            'title' => '1.8.0',
            'description' => 'API TEST5',
            // patchlevel scheint nicht zu funktionieren
        'servicepack' => 'servicepack',
        'kernel' =>'kernel',
        'patchlevel' =>'SOMETEXTHERE'

        ]
    );

print_r ($category->read($jdkID, 'C__CATG__VERSION', $entryID));

[0] => Array
    (
        [id] => 104
        [objID] => 73415
        [title] => 1.8.0
        [servicepack] => servicepack
        [kernel] => kernel
        [patchlevel] => SOMETEXTHERE
        [description] => API TEST5
    )

Actual behavior

 Array
       (
           [id] => 107
           [objID] => 73415
           [title] => 1.8.0
           [servicepack] => servicepack
           [kernel] => kernel
           [patchlevel] =>
           [description] => API TEST5
       )

Steps to reproduce the behavior

just follow my code up above, it's pretty basic..

Environment

Question Answer
bheisig/idoitapi version 0.6 via composer
PHP version 7.0.30
i-doit version 1.10.1 pro
i-doit API add-on version 1.9

Server logs

Excerpt taken from /var/log/apache2/error.log:

192.168.13.21 - - [16/Jul/2018:13:50:39 +0200] "POST /src/jsonrpc.php HTTP/1.1" 200 642 "-" "bheisig/idoitapi 0.6"
192.168.13.21 - - [16/Jul/2018:13:50:39 +0200] "POST /src/jsonrpc.php HTTP/1.1" 200 301 "-" "bheisig/idoitapi 0.6"
192.168.13.21 - - [16/Jul/2018:13:50:39 +0200] "POST /src/jsonrpc.php HTTP/1.1" 200 110 "-" "bheisig/idoitapi 0.6"
192.168.13.21 - - [16/Jul/2018:13:50:39 +0200] "POST /src/jsonrpc.php HTTP/1.1" 200 434 "-" "bheisig/idoitapi 0.6"

192.168.13.21 - - [16/Jul/2018:13:50:39 +0200] "POST /src/jsonrpc.php HTTP/1.1" 200 80 "-" "bheisig/idoitapi 0.6"


Excerpt taken from /var/www/html/i-doit/log/api_*.log:

[2018-07-16 13:52:40 0.07794100] INFO: JSON-RPC controller started for request: array (  'version' => '2.0',  'method' => 'cmdb.category.create',  'params' =>   array (    'objID' => 73415,    'data' =>     array (      'title' => '1.8.0',      'description' => 'API TEST5',      'servicepack' => 'servicepack',      'kernel' => 'kernel',      'patchlevel' => 'patchlevel',    ),    'category' => 'C__CATG__VERSION',    'apikey' => '2c6goba23d',  ),  'id' => 5,)
[2018-07-16 13:52:40 0.18825700] INFO: Transmitting response: {"jsonrpc":"2.0","result":[{"id":"109","objID":"73415","title":"1.8.0","servicepack":"servicepack","kernel":"kernel","patchlevel":"","description":"API TEST5"},{"id":"110","objID":"73415","title":"1.8.0","servicepack":"servicepack","kernel":"kernel","patchlevel":"","description":"API TEST5"},{"id":"111","objID":"73415","title":"1.8.0","servicepack":"servicepack","kernel":"kernel","patchlevel":"","description":"API TEST5"},{"id":"112","objID":"73415","title":"1.8.0","servicepack":"servicepack","kernel":"kernel","patchlevel":"","description":"API TEST5"}],"id":6}

nach update funktioniert api-login nichtmehr

Expected behavior

normal login into idoit via the api

Actual behavior

PHP Fatal error: Uncaught RuntimeException: i-doit responded with an error: i-doit system error: Unable to get userId by credentials in /var/www/itservices/ois/vendor/bheisig/idoitapi/src/API.php:630
Stack trace:
#0 /var/www/itservices/ois/vendor/bheisig/idoitapi/src/API.php(418): bheisig\idoitapi\API->evaluateResponse(Array)
#1 /var/www/itservices/ois/vendor/bheisig/idoitapi/src/API.php(338): bheisig\idoitapi\API->request('idoit.login')
#2 /var/www/itservices/ois/idoit-config.php(15): bheisig\idoitapi\API->login()
#3 /var/www/itservices/ois/fips.php(46): require_once('/var/www/itserv...')
#4 {main}
thrown in /var/www/itservices/ois/vendor/bheisig/idoitapi/src/API.php on line 630

Steps to reproduce the behavior

require_once 'vendor/autoload.php';
use bheisig\idoitapi\API;
echo "initializing API...\n";
$api = new API([
'url' => 'https://i-doit.example.net/src/jsonrpc.php',
'key' => 'XXXXXXXXX',
'username' => 'ansible',
'password' => 'YYYYYYYYYYYYYYYYY'
]);
echo "logging into idoit...\n";
$api->login();

Environment

Question Answer
bheisig/idoitapi version 0.7
PHP version 7.0.31
i-doit version 1.12 pro
i-doit API add-on version 1.10

Server logs

Excerpt taken from /var/log/apache2/error.log:

Paste logs

Excerpt taken from /var/www/html/i-doit/log/api_*.log:

Paste logs

Bug in unit test: CMDBObjectTest->testCreateWithCategories()

Expected behavior

The test testCreateWithCategories() in CMDBObjectTest.php verifies from line 233-256 the creation of three category entries by checking the content of the $result associative array.

$modelEntryID, $firstIPEntryID and $secondIPEntryID should contain the correct references (

$secondIPEntryID = $result['categories'][Category::CATG__IP][0];

):

        // Verify entries:

        $objectID = $result['id'];
        $modelEntryID = (int) $result['categories'][Category::CATG__MODEL][0];
        $firstIPEntryID = $result['categories'][Category::CATG__IP][0];
        $secondIPEntryID = $result['categories'][Category::CATG__IP][1];

Actual behavior

$secondIPEntryID contains an incorrect index and references the first IP entry of the array $result['categories'].

        // Verify entries:

        $objectID = $result['id'];
        $modelEntryID = (int) $result['categories'][Category::CATG__MODEL][0];
        $firstIPEntryID = $result['categories'][Category::CATG__IP][0];
        $secondIPEntryID = $result['categories'][Category::CATG__IP][0];

Steps to reproduce the behavior

Run the unit test CMDBObjectTest->testCreateWithCategories().

Environment

Current main branch.

vielleicht ein bug

hallo benjamin,
ich hab versucht einen entry fuer eine custom category anzulegen, mit folgendem syntax:

$entryID = $category->create(
$objectID,
'C__CATG__CUSTOM_FIELDS_MONITORINGCHECKS',
[
'f_text_c_1506087447500' => "textual-content",
'f_link_c_1506087469287' => "textual-content"
]
);

-> der eintrag wird nicht angelegt. und die api gibt mir folgendes zurueck:
[2017-09-26 14:42:50 0.07164900] INFO: JSON-RPC controller started for request: array ( 'version' => '2.0', 'method' => 'cmdb.category.create', 'params' => array ( 'objID' => 28, 'data' => array (
'f_text_c_1506087447500' => 'textual-content', 'f_link_c_1506087469287' => 'textual-content', ), 'catgID' => 'C__CATG__CUSTOM_FIELDS_MONITORINGCHECKS', 'apikey' => '5usn4n47e', ), 'id' => 5
,)
[2017-09-26 14:42:50 0.07166200] INFO: API-Key: 5usn4n47e
[2017-09-26 14:42:50 0.07167900] INFO: Logging in with RPC Session header (User: controller)
[2017-09-26 14:42:50 0.08476800] INFO: Logged in as controller
[2017-09-26 14:42:50 0.08773100] INFO: Method: create
[2017-09-26 14:42:50 0.11641700] INFO: Data: array (
)
[2017-09-26 14:42:50 0.11647600] INFO: Transmitting response: {"jsonrpc":"2.0","result":{"id":"1","message":"Category entry successfully created.","success":true},"id":5}
[2017-09-26 14:42:50 0.11649200] INFO: Request with id 5 transmitted.

mit dem custom-request geht es hingegen:
$result = $api->request("cmdb.category.create",
array(
"language"=> "en",
"category"=> "C__CATG__CUSTOM_FIELDS_MONITORINGCHECKS",
"objID"=> $objectID,
"data"=>array (
"f_text_c_1506087447500"=> "textual-content",
"f_link_c_1506087469287"=> "textual-content"
)
)
);//*/

2017-09-26 14:43:43 0.86415100] INFO: JSON-RPC controller started for request: array ( 'version' => '2.0', 'method' => 'cmdb.category.create', 'params' => array ( 'language' => 'en', 'category' => 'C
__CATG__CUSTOM_FIELDS_MONITORINGCHECKS', 'objID' => 28, 'data' => array ( 'f_text_c_1506087447500' => 'textual-content', 'f_link_c_1506087469287' => 'textual-content', ), 'apikey' => '5
usn4n47e', ), 'id' => 5,)
[2017-09-26 14:43:43 0.86417100] INFO: API-Key: 5usn4n47e
[2017-09-26 14:43:43 0.86419900] INFO: Logging in with RPC Session header (User: controller)
[2017-09-26 14:43:43 0.87787000] INFO: Logged in as controller
[2017-09-26 14:43:43 0.88046100] INFO: Method: create
[2017-09-26 14:43:43 0.92881000] INFO: Data: array (
)
[2017-09-26 14:43:43 0.92888800] INFO: Transmitting response: {"jsonrpc":"2.0","result":{"id":6,"message":"Category entry successfully created.","success":true},"id":5}
[2017-09-26 14:43:43 0.92890700] INFO: Request with id 5 transmitted.

der unterschied scheint einmal category und andernmal catgID im request zu sein.
ich hab auch versucht statt der 'constant' C__CATG__CUSTOM_FIELDS_MONITORINGCHECKS, wie der feld name es suggeriert die id dieser custom category anzugeben. aber ich weiss nicht ob ich da die richtige, art, in meinem fall '2' erwischt habe. hat jedenfalls auch nicht funktioniert.

ich hab kein problem weil ich das einfach mit dem custom request jetzt lassen werde. aber ich dachte ich schreib dir das, falls da ein bug is, und du zeit und lust hast, das zu perfektionieren.

Username for tests can't defined in .env file on windows

The environment variable username in windows environments can't be changed with .env file

Expected behavior

Connect successfully with username (=admin) defined in .env-File

Actual behavior

Connection fails, because of wrong username.
The username is set to the username with the user logged into windows.
However, this username can differ from the username defined in the .env file

Steps to reproduce the behavior

Changing the environment variable to IDOIT_USERNAME works:

File: .env
IDOIT_USERNAME=admin

File: BaseTest.php
Method: setUp()
Line: 143
if (getenv('IDOIT_USERNAME') !== false && getenv('PASSWORD') !== false) {
$config[API::USERNAME] = getenv('IDOIT_USERNAME');
$config[API::PASSWORD] = getenv('PASSWORD');
}

Environment

Windows

Restore von Objekten

Hallo,
ich würde gerne in CMDBObject.php die Restore-Funktion benutzen. Ein Status-Update scheint ja nicht zu klappen.
Gibt es über die API evtl. eine andere Möglichkeit, wie man Objekte wiederherstellen kann? Ist etwas in der Art in Planung? Oder muss ich weiterhin auf die Restore-Funktion verzichten? Damit ist eine Sync-Schnittstelle leider nur schwer abzubilden...

Viele Grüße
Michael

Api funktioniert nicht nach Update auf v1.16.2

Hallo,
nach dem Update auf die aktuelle Pro Version 1.16.2 habe ich wie beschrieben mittels composer die Api wieder installiert. Dabei scheint aber ein Downgrade an einigen Paketen zu erfolgen. Dies hat den Effekt, dass Fehler in I-doit auftreten.

bheisig/idoitapi version 0.10.0
i-doit version 1.16.2
i-doit API add-on version 1.12.1

Hier die Ausgabe von composer:
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^0.10.0 for bheisig/idoitapi
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 15 installs, 30 updates, 11 removals

  • Removing symfony/string (v5.1.8)
  • Removing symfony/service-contracts (v2.2.0)
  • Removing symfony/polyfill-php80 (v1.22.0)
  • Removing symfony/polyfill-php73 (v1.22.0)
  • Removing symfony/polyfill-intl-normalizer (v1.22.0)
  • Removing symfony/polyfill-intl-grapheme (v1.22.0)
  • Removing symfony/event-dispatcher-contracts (v2.2.0)
  • Removing symfony/deprecation-contracts (v2.2.0)
  • Removing psr/http-client (1.0.1)
  • Removing psr/event-dispatcher (1.0.0)
  • Removing intervention/image (2.5.1)
  • Downgrading composer/semver (3.2.4 => 1.5.1): Downloading (100%)
  • Downgrading ezyang/htmlpurifier (v4.13.0 => v4.12.0): Downloading (100%)
  • Downgrading guzzlehttp/psr7 (1.7.0 => 1.6.1): Downloading (100%)
  • Downgrading guzzlehttp/promises (1.4.0 => v1.3.1): Downloading (100%)
  • Installing symfony/polyfill-php72 (v1.15.0): Downloading (100%)
  • Downgrading symfony/polyfill-mbstring (v1.22.0 => v1.15.0): Downloading (100%)
  • Installing paragonie/random_compat (v9.99.99): Downloading (100%)
  • Installing symfony/polyfill-php70 (v1.15.0): Downloading (100%)
  • Installing symfony/polyfill-intl-idn (v1.15.0): Downloading (100%)
  • Downgrading guzzlehttp/guzzle (7.2.0 => 6.5.3): Downloading (100%)
  • Downgrading hackzilla/password-generator (1.6.0 => 1.5.0): Downloading (100%)
  • Downgrading league/csv (9.6.2 => 7.2.0): Downloading (100%)
  • Downgrading monolog/monolog (2.2.0 => 1.25.3): Downloading (100%)
  • Downgrading symfony/translation-contracts (v2.3.0 => v1.1.7): Downloading (100%)
  • Downgrading symfony/translation (v4.4.16 => v4.4.7): Downloading (100%)
  • Installing symfony/contracts (v1.1.0): Downloading (100%)
  • Downgrading nesbot/carbon (2.45.0 => 2.32.2): Downloading (100%)
  • Downgrading pagerfanta/pagerfanta (v2.5.1 => v2.1.3): Downloading (100%)
  • Downgrading phpmailer/phpmailer (v6.2.0 => v5.2.28): Downloading (100%)
  • Downgrading phpseclib/phpseclib (2.0.28 => 2.0.27): Downloading (100%)
  • Downgrading simplepie/simplepie (1.5.6 => 1.5.4): Downloading (100%)
  • Downgrading smarty/smarty (v3.1.36 => v3.1.33): Downloading (100%)
  • Downgrading symfony/class-loader (v3.4.46 => v3.4.39): Downloading (100%)
  • Downgrading symfony/polyfill-ctype (v1.22.0 => v1.15.0): Downloading (100%)
  • Downgrading symfony/filesystem (v5.1.8 => v4.4.7): Downloading (100%)
  • Downgrading symfony/config (v5.1.8 => v3.4.39): Downloading (100%)
  • Installing symfony/debug (v4.4.7): Downloading (100%)
  • Downgrading symfony/console (v5.1.8 => v3.4.39): Downloading (100%)
  • Downgrading symfony/dependency-injection (v5.1.8 => v3.4.39): Downloading (100%)
  • Downgrading symfony/event-dispatcher (v5.1.8 => v3.4.39): Downloading (100%)
  • Downgrading symfony/http-foundation (v5.1.8 => v3.4.39): Downloading (100%)
  • Downgrading symfony/polyfill-iconv (v1.22.0 => v1.15.0): Downloading (100%)
  • Downgrading symfony/security-core (v5.1.8 => v4.2.12): Downloading (100%)
  • Installing symfony/polyfill-util (v1.15.0): Downloading (100%)
  • Installing symfony/polyfill-php56 (v1.15.0): Downloading (100%)
  • Downgrading symfony/security-csrf (v5.1.8 => v3.4.39): Downloading (100%)
  • Downgrading symfony/yaml (v5.1.8 => v3.4.39): Downloading (100%)
  • Installing bheisig/idoitapi (0.10): Downloading (100%)
  • Installing patchwork/utf8 (v1.3.2): Downloading (100%)
  • Installing doctrine/inflector (1.3.1): Downloading (100%)
  • Installing anahkiasen/underscore-php (2.0.0): Downloading (100%)
  • Downgrading symfony/process (v5.1.8 => v4.4.7): Downloading (100%)
  • Installing knplabs/knp-snappy (v1.2.1): Downloading (100%)
  • Installing latitude/latitude (0.7.0): Downloading (100%)
  • Installing symfony/options-resolver (v3.4.39): Downloading (100%)
    paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
    symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
    symfony/contracts suggests installing psr/cache (When using the Cache contracts)
    symfony/contracts suggests installing symfony/cache-contracts-implementation
    symfony/contracts suggests installing symfony/event-dispatcher-implementation
    symfony/contracts suggests installing symfony/http-client-contracts-implementation
    symfony/contracts suggests installing symfony/service-contracts-implementation
    symfony/contracts suggests installing symfony/translation-contracts-implementation
    bheisig/idoitapi suggests installing ext-xdebug (Needed for code coverage with phpunit)
    patchwork/utf8 suggests installing ext-wfio (Use WFIO for UTF-8 filesystem access on Windows)
    patchwork/utf8 suggests installing ext-intl (Use Intl for best performance)
    knplabs/knp-snappy suggests installing h4cc/wkhtmltopdf-amd64 (Provides wkhtmltopdf-amd64 binary for Linux-compatible machines, use version ~0.12 as dependency)
    knplabs/knp-snappy suggests installing h4cc/wkhtmltopdf-i386 (Provides wkhtmltopdf-i386 binary for Linux-compatible machines, use version ~0.12 as dependency)
    knplabs/knp-snappy suggests installing h4cc/wkhtmltoimage-amd64 (Provides wkhtmltoimage-amd64 binary for Linux-compatible machines, use version ~0.12 as dependency)
    knplabs/knp-snappy suggests installing h4cc/wkhtmltoimage-i386 (Provides wkhtmltoimage-i386 binary for Linux-compatible machines, use version ~0.12 as dependency)
    knplabs/knp-snappy suggests installing wemersonjanuario/wkhtmltopdf-windows (Provides wkhtmltopdf executable for Windows, use version ~0.12 as dependency)
    Package patchwork/utf8 is abandoned, you should avoid using it. Use symfony/polyfill-mbstring or symfony/string instead.
    Package anahkiasen/underscore-php is abandoned, you should avoid using it. No replacement was suggested.
    Writing lock file
    Generating autoload files

Hier der I-doit Fehler z.B. beim Aufruf der console.php:
PHP Fatal error: Uncaught Error: Class 'idoit\Component\ClassLoader\MapClassLoader' not found in /var/www/html/i-doit/src/autoload.inc.php:271
Stack trace:
#0 /var/www/html/i-doit/src/bootstrap.inc.php(36): include_once()
#1 /var/www/html/i-doit/console.php(14): require('/var/www/html/i...')
#2 {main}
thrown in /var/www/html/i-doit/src/autoload.inc.php on line 271

cmdb.category.create gibt deprecation warning und runtimeexception

ich mach category->read(..)
und bekomme ein leeres array,also mache ich
category->create(...)..

dabei tritt folgender fehler auf..

ich wollte das nur grob melden, zu deiner information;

ich werd mal schauen das ich die exception abfange und einfach weitermache..

gruesse,
PK

Expected behavior

creating the group membership category

Actual behavior

PHP Fatal error: Uncaught RuntimeException: Bad result: Category entry was already existing and has been updated. [This method is deprecated und will be removed i
n a feature release. Use 'cmdb.category.save' instead.] in /var/www/itservices/ois/vendor/bheisig/idoitapi/src/CMDBCategory.php:104
Stack trace:
#0 /var/www/itservices/ois/idoit-syncdoc.php(399): bheisig\idoitapi\CMDBCategory->create(148915, 'C__CATG__GROUP_...', Array)

Steps to reproduce the behavior

Environment

Question Answer
bheisig/idoitapi version 0.7
PHP version 7.2
i-doit version 1.12.1 mit hotfixes fuer api open/pro
i-doit API add-on version latest

Server logs

Excerpt taken from /var/log/apache2/error.log:

Paste logs

Excerpt taken from /var/www/html/i-doit/log/api_*.log:

Paste logs

The requested URL returned error: 403

Expected behavior

Hello World Example returns the i-doit version

Actual behavior

I'm getting the following error:

PHP Fatal error:  Uncaught Exception: The requested URL returned error: 403 in /opt/scripts/vendor/bheisig/idoitapi/src/API.php:512
Stack trace:
#0 /opt/scripts/vendor/bheisig/idoitapi/src/API.php(405): bheisig\idoitapi\API->execute(Array)
#1 /opt/scripts/vendor/bheisig/idoitapi/src/Idoit.php(40): bheisig\idoitapi\API->request('idoit.version')
#2 /opt/scripts/apiclient.php(16): bheisig\idoitapi\Idoit->readVersion()
#3 {main}
  thrown in /opt/scripts/vendor/bheisig/idoitapi/src/API.php on line 512

Steps to reproduce the behavior

Try using the provided "Hello, World!" example (change the API variables to your need ofc), mine looks like this:

#!/usr/bin/php
<?php
use bheisig\idoitapi\API;
use bheisig\idoitapi\Idoit;

require_once 'vendor/autoload.php';

$api = new API([
    'url' => 'https://_yourserver_/src/jsonrpc.php',
    'key' => '_yourapikey_',
    'username' => '_yourusername_',
    'password' => '_yourpassword_'
]);

$request = new Idoit($api);
$info = $request->readVersion();

var_dump($info);
?>

### Underscored text has been altered

Environment

Question Answer
bheisig/idoitapi version 0.4
PHP version 7.0.29
i-doit version 1.10.1 pro
i-doit API add-on version 1.9

Server logs

Excerpt taken from /var/log/apache2/error.log:

sadly the log doesn't show anything when executing the script

Excerpt taken from /var/www/html/i-doit/log/api_*.log:

same here, no information is logged

When i do a "manual" curl api call it works fine with the same api url/key/user.
That's why it shouldn't be a permission problem, right?

Unit-Test "bheisig\idoitapi\tests\Issues\API145Test" fails

Expected behavior

Unit-Test does not fail.

Actual behavior

Unit-Test works as expected.

Steps to reproduce the behavior

Run unit test.

Environment

Question Answer
bheisig/idoitapi version master
i-doit version 1.15 pro
i-doit API add-on version bugfix

Logs and other useful output

Problems in "testAssignSingleObject":

  • Passing in objectId as integer for multi selection properties
  • Using of undefined category constant "C__CATG__STACKING"

Problems in "testAssignMultipleObjects"

  • Expecting exception which is never thrown

Installation instructions don't work

Hello everyone,

The standard installation does not work according to the instructions.
Error message occurs on a Linux with Apache2 and PHP 8.2

Fatal error: Uncaught Error: Class "Idoit\APIClient\API" not found in /var/www/test/idoit-api/api.php:12 Stack trace: #0 {main} thrown in /var/www/test/idoit-api/api.php on line 12

My Code
`use Idoit\APIClient\API;
use Idoit\APIClient\Idoit;

require_once 'vendor/autoload.php';

$api = new API([
API::URL => 'https://demo.i-doit.com/src/jsonrpc.php',
API::KEY => 'c1ia5q',
API::USERNAME => 'admin',
API::PASSWORD => 'admin'
]);

$request = new Idoit($api);
$info = $request->readVersion();

var_dump($info);`

My environment:
Debian 12, Apache 2.4.57-2 , PHP 8.2.7-1~deb12u1

phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n"

Actual behavior

phpcs on windows throws on every file following error: End of line character is invalid; expected "\n" but found "\r\n"

FILE: ...\MAMP\htdocs\api-client-php\tests\Idoit\APIClient\SubnetTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Found this Issue:
squizlabs/PHP_CodeSniffer#2554

Steps to resolve the behavior

I'm not firm with phpcs, so I can't judge if my successful test can be a solution!

  1. create ruleset.xlm from following link
    https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/src/Standards/PSR2/ruleset.xml

  2. Change eolChar from "\n" to "\r\n"

    <rule ref="Generic.Files.LineEndings">
        <properties>
            <property name="eolChar" value="\r\n"/>
        </properties>
    </rule>
  1. comment excludes
<!-- checked by PSR2.Classes.ClassDeclaration -->
<!-- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/> -->
  1. add script in composer.json

"phpcs-win": "./vendor/bin/phpcs --standard=ruleset.xml --extensions=php src/ tests/",

  1. Test works fine

composer phpcs-win

Environment

Windows

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.