Skip to content

Example: Command list (commands.xml)

Chris edited this page May 26, 2016 · 2 revisions

Options

The parser implementation (pandaac\Exporter\Parsers\Commands in this case) has no options.

Example

use pandaac\Exporter\Exporter;
use pandaac\Exporter\Parsers\Commands;

try {

  $commands = new Exporter(
    './data/XML/commands.xml',
    new Commands
  );

  $response = $commands->export();

} catch (Exception $e) {
  // Log errors...
}

The export() method returns a Illuminate\Support\Collection object, please refer to its documentation. If you would prefer a JSON or an array response however, you may do as follows...

$response = $commands->export()->toJson();
$response = $commands->export()->toArray();

Example output (JSON)

[
  {
    "cmd": "/reload",
    "group": 2,
    "acctype": 5,
    "log": "yes"
  },
  {
    "cmd": "/raid",
    "group": 2,
    "acctype": 4,
    "log": "yes"
  },
  {
    "cmd": "!sellhouse",
    "group": 1,
    "acctype": 1,
    "log": "no"
  },

  ...
]

Clone this wiki locally