exelearning / elp-parser
Parse eXeLearning .elp files
v0.0.6
2025-02-02 20:25 UTC
Requires
- php: ^8.0
Requires (Dev)
README
Simple, fast, and extension-free parser for eXeLearning project files
Features | Installation | Usage
Features
ELP Parser provides a simple and intuitive API to parse eXeLearning project files (.elp):
- Parse both version 2 and version 3 .elp files
- Extract text content from XML
- Detect file version
- Extract entire .elp file contents
- No external extensions required
- Lightweight and easy to use (less than 4 KB footprint library)
- Compatible with PHP 8.0 to PHP 8.5
For more information, visit the documentation.
Requirements
- PHP 8.0+
- Composer
- zip extension
Installation
Install the package via Composer:
composer require exelearning/elp-parser
Usage
Basic Parsing
use Exelearning\ELPParser; try { // Parse an .elp file $parser = ELPParser::fromFile('/path/to/your/project.elp'); // Get the file version $version = $parser->getVersion(); // Returns 2 or 3 // Get metadata fields $title = $parser->getTitle(); $description = $parser->getDescription(); $author = $parser->getAuthor(); $license = $parser->getLicense(); $language = $parser->getLanguage(); // Get all extracted strings $strings = $parser->getStrings(); // Print extracted strings foreach ($strings as $string) { echo $string . "\n"; } } catch (Exception $e) { echo "Error parsing ELP file: " . $e->getMessage(); }
File Extraction
use Exelearning\ELPParser; try { $parser = ELPParser::fromFile('/path/to/your/project.elp'); // Extract entire .elp contents to a directory $parser->extract('/path/to/destination/folder'); } catch (Exception $e) { echo "Error extracting ELP file: " . $e->getMessage(); }
Advanced Usage
// Convert parsed data to array $data = $parser->toArray(); // JSON serialization $jsonData = json_encode($parser);
Error Handling
The parser includes robust error handling:
- Detects invalid .elp files
- Throws exceptions for parsing errors
- Supports both version 2 and 3 file formats
Performance
- Lightweight implementation
- Minimal memory footprint
- Fast XML parsing using native PHP extensions
Contributing
Contributions are welcome! Please submit pull requests or open issues on our GitHub repository.
License
The MIT License (MIT). Please see License File for more information.