- What is goetas/xsd2php used for in a Laravel project?
- goetas/xsd2php is a build-time generator that converts XML Schema (XSD) and WSDL definitions into PHP DTO classes and JMS Serializer metadata. In Laravel it is useful only when you need contract-first XML or SOAP integration driven by external schemas. The generated classes should be isolated behind application services rather than treated like Eloquent models or Laravel resources.
- Is goetas/xsd2php compatible with Laravel and PHP 8?
- There is no official Laravel integration, and the package was last released in 2016 and is archived. It has no PHP 8.x compatibility guarantee, and its old jms/serializer, doctrine/annotations, and Symfony Console constraints may conflict with modern Laravel and PHP versions. Run composer why-not against your target versions before committing, and expect to fork or replace it if upgrades block dependencies.
- How do I install goetas/xsd2php in Laravel?
- Install it as a development or build dependency with Composer, ideally in a disposable branch first because the archived dependency graph may conflict with a current Laravel application. There is no Laravel service provider, config publishing, or framework integration to register. Generated classes can be committed into a dedicated integration namespace, or produced as build artifacts in CI.
- Does goetas/xsd2php integrate with Eloquent or Laravel validation?
- No. The generated classes are plain PHP DTOs with JMS Serializer metadata, not Eloquent models, form requests, or Laravel API resources. You should wrap them in application-owned adapters and map them to internal DTOs or models before exposing data to controllers, Blade views, or validation layers. This keeps the XML binding stack from leaking into Laravel conventions.
- How do I generate PHP classes from an XSD or WSDL with goetas/xsd2php?
- Use the package CLI to point at an XSD or WSDL file and configure the target namespace and output directory. Generation can run manually, in a Composer script, or in CI, and the resulting PHP classes and serializer metadata can be checked in or treated as build artifacts. Start with one representative schema and validate round-trip serialization against sample payloads before expanding.
- Does goetas/xsd2php require JMS Serializer at runtime?
- Yes, the generated metadata is designed for JMS Serializer-based XML serialization and deserialization. That adds a parallel serialization stack to Laravel’s JSON-centric conventions, so keep JMS usage behind an application-owned XmlGateway or SchemaSerializer service. Bind that service in a Laravel service provider and inject it into jobs, commands, or handlers instead of using JMS directly in controllers.
- Can I use goetas/xsd2php for SOAP web services in Laravel?
- It can generate typed PHP models from WSDL and XSD definitions, which is useful for contract-first SOAP payload handling. It does not provide a complete Laravel SOAP client or transport layer, so you still need an HTTP/SOAP client and application service around the generated DTOs. Treat it as a schema-to-class generator, not as a full SOAP framework.
- Is goetas/xsd2php still maintained, and what are the risks?
- The repository is archived and the last release was in 2016, so there are no upstream fixes, PHP 8 compatibility guarantees, or security maintenance. The main risks are dependency drift, incomplete handling of XSD edge cases such as imports, includes, substitution groups, and xs:choice, and XML parsing security. Plan to fork and maintain the generator if PHP or Laravel upgrades block the upstream dependencies.
- What alternatives to goetas/xsd2php should I consider for Laravel?
- Consider a maintained fork, Jane PHP, Symfony Serializer with custom XML normalizers, or hand-written DTOs with a focused XML mapper. The right choice depends on whether you need full round-trip fidelity, only deserialization into internal DTOs, or a short-term legacy bridge. Keep application contracts independent of generated classes so the serializer can be swapped later.
- How should I secure XML parsing and test generated classes with goetas/xsd2php?
- Explicitly disable external entities and network access in the XML parser to prevent XXE attacks, and set size and depth limits appropriate to your payloads. Test generated classes with representative sample XML, round-trip serialization and deserialization, and edge cases like namespaces, imports, includes, and xs:choice. Run the integration behind a feature flag in parallel with the existing path for at least one release cycle before relying on it in production.