Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Xml Laravel Package

veewee/xml

Type-safe, declarative XML toolkit for PHP. Includes DOM helpers, safe error handling, memory-safe reader/writer, XML encode/decode, plus XSD and XSLT utilities. Spec-compliance ready for PHP 8.4+, with maintained v3 for older PHP.

View on GitHub
Deep Wiki
Context7

XML without worries

Frequently asked questions about Xml
How does veewee/xml prevent XXE attacks in Laravel applications?
veewee/xml includes a `disallow_doctype()` configurator in its Writer component, which blocks XML DOCTYPE declarations—a common XXE attack vector. For Laravel, integrate this in middleware or validation to sanitize incoming XML requests. The package also provides fluent methods to enforce DOCTYPE-free XML globally or per-operation.
Can I use veewee/xml with Laravel’s validator for XML schema validation?
Yes, the package’s XSD utilities integrate with Laravel’s validation system. Use `XmlSchemaValidator::disallowDoctype()` to enforce security alongside schema checks. For example, validate XML payloads in API requests with `validator()->extend('xml_schema', function ($attribute, $value, $parameters) { ... })` and combine it with DOCTYPE restrictions.
What’s the upgrade path from veewee/xml v3 to v4 for PHP 8.4+ compliance?
v4 requires PHP 8.4+ and enables opt-in DOM spec compliance, while v3 remains actively maintained for PHP 8.1–8.3. Audit your code for DOCTYPE dependencies (v4 disables them by default) and test memory-safe readers/writers. Use the [support table](https://github.com/veewee/xml#support-table) to pick the right version for your Laravel environment.
How do I configure veewee/xml to disallow DOCTYPE globally in a Laravel app?
Bind the `XmlWriterInterface` in Laravel’s service container with `disallow_doctype()` set to `false` in `config/services.php`. Extend the `Xml` facade to include a global method like `Xml::writer()->disallowDoctype()` or use middleware to enforce it per-request. Example: `Xml::writer()->disallowDoctype()->write($xmlString)`.
Does veewee/xml support large XML files in Laravel without memory issues?
Yes, the package includes memory-safe `Reader` and `Writer` components optimized for bulk processing. For Laravel, use these for data exports/imports (e.g., `Model::toXml()->writer()->disallowDoctype()`). Benchmark with large files to ensure no performance regression after enabling `disallow_doctype()`, as it adds minimal overhead.
Are there Laravel-specific security middleware examples for veewee/xml?
Create `XmlDoctypeSanitizerMiddleware` to parse and sanitize XML requests. Example: `public function handle(Request $request, Closure $next) { $xml = $request->xml(); $xml->disallowDoctype()->validate(); return $next($request); }`. Pair this with Laravel’s `ValidateXml` rule to enforce DOCTYPE-free XML in API contracts.
What alternatives exist for XML processing in Laravel if veewee/xml lacks XSLT/XSD features?
For XSLT/XSD, consider `spatie/xml-to-array` (simpler but no DOCTYPE control) or integrate PHP’s native `DOMDocument` with custom DOCTYPE filters. For advanced XSLT 3.0, wait for `veewee/xml`’s Saxon/C roadmap (PHP 8.4+). For Laravel, combine `veewee/xml`’s security features with third-party tools like `ext-saxon` for transformations.
How do I test veewee/xml’s DOCTYPE protection in Laravel unit tests?
Test edge cases: malformed XML with DOCTYPE, namespaced declarations, and mixed inputs. Use Laravel’s `XmlReader::validate()->disallowDoctype()` in tests. Example: `$reader = new XmlReader(); $reader->disallowDoctype()->parse($maliciousXml); $this->assertFalse($reader->hasErrors());`. Mock HTTP requests with DOCTYPE payloads to validate middleware.
Will veewee/xml break existing Laravel apps using DOCTYPE in XML generation?
Yes, v4 disables DOCTYPE by default, which may break legacy XML schemas or third-party integrations. Audit your XML generation/parsing logic for DOCTYPE dependencies. Mitigate by whitelisting trusted sources or using v3.x (PHP 8.1–8.3) if DOCTYPE is required. The package provides no silent fallback—errors will occur if DOCTYPE is used.
Can I use veewee/xml’s `xml_encode()`/`xml_decode()` like JSON in Laravel APIs?
Absolutely. The package’s encoding utilities let you serialize/deserialize XML like JSON. Example: `$xmlString = xml_encode(['data' => $array]);` or `$array = xml_decode($xmlString)`. Integrate with Laravel’s API responses via `Response::json(xml_encode($data))` or parse XML requests with `xml_decode($request->getContent())`.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor