mistralys / x4-core
Database and utility classes used to access X4: Foundations game data in an OOP way.
Fund package maintenance!
Requires
- php: >=8.4
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-simplexml: *
- components/jquery: >=3.5.1
- fortawesome/font-awesome: ^5.15
- mistralys/application-localization: >=2.1.1
- mistralys/application-utils: >=2.3.2
- mistralys/application-utils-core: >=2.3.12
- mistralys/x4-data-extractor: >=2.0.0
- symfony/css-selector: >=v7.2.0
- thomaspark/bootswatch: ^v5.1.3
- twbs/bootstrap: ^v5.1.3
Requires (Dev)
- phpstan/phpstan: >=1.6.1
- phpunit/phpunit: >=9.5.20
- roave/security-advisories: dev-latest
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Access X4: Foundations game data from PHP, without parsing game files yourself.
LAST VERIFIED: November 2026 | X4 Foundations 9.0, Empire Update.
What is X4 Core?
X4 Core is a PHP library that gives you factions, wares, ships, station modules and blueprints from X4: Foundations as plain objects. The extracted game data ships with the package, so you can query it right after installing. It is built to be a dependency for your own X4 tools, mods and websites.
Features
- Look up factions, wares, ships, station modules and blueprints through a consistent object API.
- Narrow down results with chainable finders, for example by ware group or by the DLC that provides an item.
- Translate game text codes such as
{20101,20604}using the bundled official translations. - Read the extracted data directly as JSON files if you prefer not to use the PHP classes.
- Regenerate the bundled data from your own game installation with a Composer command.
- Build web pages around the data with the included Bootstrap-based UI components.
Requirements
- PHP 8.4 or higher
- PHP extensions:
simplexml,json,mbstring,dom,curl - Composer
Quick Start
Install the package in your Composer project:
composer require mistralys/x4-core
Then create a script that looks up a faction and finds the ship engines added by the Boron DLC:
<?php require_once __DIR__ . '/vendor/autoload.php'; use Mistralys\X4\Database\DataSources\KnownDataSources; use Mistralys\X4\Database\Factions\KnownFactions; use Mistralys\X4\Database\Wares\WareDefs; use Mistralys\X4\Database\Wares\WareGroups; echo KnownFactions::getInstance()->getArgonFederation()->getLabel() . PHP_EOL; $engines = WareDefs::getInstance() ->findWares() ->selectDataSource(KnownDataSources::DATA_SOURCE_KINGDOM_END) ->selectGroup(WareGroups::GROUP_ENGINES) ->getAll(); foreach ($engines as $engine) { echo $engine->getLabel() . PHP_EOL; }
The first line printed is the faction name:
Argon Federation
The lines after it are the labels of the matching Boron engines.
Learn More
| Resource | Description |
|---|---|
| Usage guide | Factions, wares, the ware finder and translations |
| Ship handbook | Ship data API reference for library users |
| Development setup | Configure the project and rebuild the bundled data from your game files |
| Public API reference | Public class and method signatures, grouped by domain |
| Project manifest | Architecture, patterns and conventions |
| Extraction reference | How game data is extracted, and how to rebuild the database |
| Changelog | Release history, including breaking data changes |
|
Related X4 projects
- X4 Data Extractor – Unpacks the game data files.
- X4 Savegame Parser – Extracts information from savegames.
- X4 Cargo Size Mod – A mod that increases ship cargo sizes.
- X4 Game Notes – How-tos, tips and general information about X4.
