Skip to main content

Requirements

Before installing Laravel XML, ensure your environment meets these requirements:
  • PHP 8.0 or higher
  • Laravel 8.47 or higher
  • PHP extensions: ext-dom, ext-simplexml, ext-json
These extensions are typically enabled by default in most PHP installations.

Install via Composer

Install the package using Composer:
composer require flowgistics/laravel-xml
The package will be downloaded and added to your composer.json file automatically.

Service provider registration

Laravel XML supports package auto-discovery, which means the service provider and facade are registered automatically when you install the package. You can immediately start using the XML facade in your application without any additional configuration:
use XML;

$data = XML::import('data.xml')->get();
If you’ve disabled package auto-discovery in your Laravel application, you’ll need to manually register the service provider in config/app.php:
'providers' => [
    // Other service providers...
    Flowgistics\XML\XMLServiceProvider::class,
],
And the facade:
'aliases' => [
    // Other aliases...
    'XML' => Flowgistics\XML\XMLFacade::class,
],

Optional dependencies

If you plan to use the view export feature to render Laravel Blade views as XML, ensure you have the illuminate/view package installed. This is included by default in standard Laravel installations:
{
  "require": {
    "illuminate/view": ">=8.47"
  }
}

Verify installation

To verify Laravel XML is installed correctly, try importing a simple XML file:
1

Create a test XML file

Create a file called test.xml in your project root:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <message>Hello from Laravel XML!</message>
</root>
2

Import the file in tinker

Open Laravel Tinker and import the file:
php artisan tinker
>>> $xml = \XML::import('test.xml')->get();
>>> $xml->message;
=> "Hello from Laravel XML!"
3

Celebrate

If you see the message output, Laravel XML is installed and working correctly!

Next steps

Now that you have Laravel XML installed, proceed to the quickstart guide to learn the basics:

Quickstart

Learn how to import and export XML with a complete working example

Build docs developers (and LLMs) love