Export to files¶
PhpTabs::save($filename, $format = null)¶
The save()
method may be used to store file contents on a disk.
use PhpTabs\IOFactory;
$filename = 'my-file.gp5';
// Read and parse file
$song = IOFactory::fromFile($filename);
$song->save('my-file.mid');
The destination format is recognized by the file extension (gp3, gp4, gp5, mid, midi, json, ser, yml, xml) and the song is implicitly converted to this format.
The following formats are available:
gp3
for Guitar Pro 3gp4
for Guitar Pro 4gp5
for Guitar Pro 5mid
ormidi
for MIDIjson
xml
ser
for PHP serialized stringtxt
ortext
for a textual representationyml
oryaml
If the file extension is not standard, a format may be passed as the second parameter.
Of course, you may read, convert and save in one line.
use PhpTabs\IOFactory;
$filename = 'my-file.gp5';
// The Guitar Pro file is parsed, converted
// and recorded as a JSON string
IOFactory::fromFile($filename)
->save('my-file.dat', 'json');