- How do I install goetas/xsd-reader in a Laravel project?
- Install it with Composer by running composer require goetas/xsd-reader. The library is framework-agnostic, so it does not register a Laravel service provider or facade. You can use its classes directly in controllers, jobs, or service classes, and optionally bind a configured reader instance in a service provider.
- Does goetas/xsd-reader work with Laravel 10 and Laravel 11?
- Yes, it can be used with Laravel 10 and 11 because it is a plain PHP package with no Laravel-specific dependencies. Actual compatibility depends on the PHP version required by the goetas/xsd-reader release you install, so check its composer.json constraints. Run your test suite on the target Laravel and PHP versions before upgrading.
- How do I parse an XSD file into PHP objects with goetas/xsd-reader?
- Instantiate the schema reader from the package and pass it your XSD file path or XML string. The reader returns an object model containing elements, types, attributes, and groups. You can then traverse that model to generate code, inspect definitions, or build XML tooling.
- What XSD features does goetas/xsd-reader support?
- It supports schema imports and includes, simple and complex types, elements, attributes, groups, and annotations. That coverage makes it suitable for reading typical XSD schemas into an object model. For features not covered by your schema, test parsing early and inspect the resulting model.
- Can goetas/xsd-reader validate XML documents against an XSD?
- The library reads XSD schemas into an object model; it is not primarily an XML instance validator. For validation in Laravel, you can use PHP's DOMDocument::schemaValidate or another validator and use goetas/xsd-reader for schema inspection or code generation. This separation keeps parsing and validation concerns clear.
- How do I handle XSD imports and includes with goetas/xsd-reader?
- The reader supports XSD imports and includes and resolves referenced schemas as part of parsing. Make sure the schema location paths are reachable from your application and that any custom resolution logic matches your deployment layout. In Laravel, store schemas in a known directory and build absolute paths before reading.
- Is goetas/xsd-reader good for XSD-driven code generation?
- Yes, its object model is designed for tooling such as XSD-driven code generation and is used by related projects in the goetas ecosystem. You can traverse types and elements to generate PHP classes, DTOs, or configuration. Cache generated output rather than regenerating on every request.
- What are alternatives to goetas/xsd-reader for PHP?
- Alternatives include other PHP XSD parsing libraries and hand-rolled DOMDocument-based readers tailored to your schema. goetas/xsd-reader is a focused parser with support for imports, includes, types, elements, attributes, groups, and annotations. Choose based on whether you need a full object model, validation, or only lightweight schema inspection.
- How should I test code that uses goetas/xsd-reader in Laravel?
- Keep small fixture XSD files in your test suite and parse them with the reader to assert the expected object model. Use Laravel's testing helpers for the surrounding application code, but test the reader integration as plain PHP. Include cases for imports, includes, and any schema features your application relies on.
- Is goetas/xsd-reader actively maintained and safe for production?
- Check the repository's releases, open issues, and recent commits before adopting it, since maintenance activity can change over time. Pin a specific version in composer.json and review the changelog when updating. For production, add tests around the schemas you parse and monitor for PHP version compatibility.