salsify/jsonstreamingparser

Need more explanation on how to use the library without composer

Opened this issue · 1 comments

I get this error after installing the library with composer:

PHP Fatal error:  Uncaught Error: Class 'JsonStreamingParser\Listener\InMemoryListener' not found in /data/www/default/database/json_to_sql.php:14
Stack trace:
#0 {main}
  thrown in /data/www/default/database/json_to_sql.php on line 14

json_to_sql.php

require_once 'vendor/autoload.php';
$json_file = dirname(__FILE__) . "file.json";

# Load json data from the file into a variable
Line 14 -> $listener = new \JsonStreamingParser\Listener\InMemoryListener();

$stream = fopen($json_file, 'r');
try {
    $parser = new \JsonStreamingParser\Parser($stream, $listener);
    $parser->parse();
    fclose($stream);
} catch (Exception $e) {
    fclose($stream);
    throw $e;
}

$json_data = $listener->getJson();
var_dump($json_data);

I've installed the library with downloading the composer.json file and doing php composer.phar install.

$ php composer.phar diagnose                                              
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: 

  [Symfony\Component\Process\Exception\RuntimeException]
  The Process class relies on proc_open, which is not available on your PHP installation.

diagnose

When I clone the repository it gives me the same error. I don't know if I have to do an include or something, there is no example.

this seems to be a php issue for you to be able to run composer. It seems that composer wishes to run a few git commands to test things. for that it needs to be able to execute git.
This causes autoload not to be generated or files properly loaded.

Just a hunch. Check your php settings.