0

I would like to use php library in symfony2 Command. http://phpmidiparser.com/quickstart

I put the library on the same folder of symfony2 but in vain.

Command/Midi/bootstrap.php
Command/myCommand.php
$ php app/console top:myCommand

syntax error, unexpected 'use' (T_USE) in error at use \Midi\Parsing\FileParser;

require_once 'Midi/bootstrap.php';

use \Midi\Parsing\FileParser;
use \Midi\Reporting\TextFormatter;
use \Midi\Reporting\Printer;

$parser = new FileParser();
$parser->load('/path/to/midi/file.mid');

$printer = new Printer(new TextFormatter(), $parser);
$printer->printAll();

I use this library only in Command ,so I don't need to register this on autoload.

Please teach me basic guideline of using external library, where should I put the library and how can I 'require'?

1 Answer 1

1

usekeyword must appear before require_once (http://php.net/manual/en/language.namespaces.importing.php)

use \Midi\Parsing\FileParser;
use \Midi\Reporting\TextFormatter;
use \Midi\Reporting\Printer;

require_once 'Midi/bootstrap.php';

$parser = new FileParser();
$parser->load('/path/to/midi/file.mid');

$printer = new Printer(new TextFormatter(), $parser);
$printer->printAll();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.