MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

PortableContent

MMO\admin\helpers · 1 symbole · générée le 30 Nov 2026

class

PortableContent

PortableContent.php:26

Makes the data a site wrote usable by the same site elsewhere: the absolute addresses of one of its copies -- its urls, the folders it runs from -- are written relative, so what production saved still works here, and the other way round (DataSync).

class MMO\admin\helpers\PortableContent
Espace de noms
MMO\admin\helpers
- an url of the site, `https://site.com/base/assets/x.jpg`, becomes `assets/x.jpg`: relative to the application, as mmo.editor writes its images and links already; the site's url alone becomes `./`. Its `http:` and `https:` forms, the protocol-relative `//site.com/base/`, and JSON's escaped `https:\/\/site.com\/` are all recognised. - a folder of the site, `/var/www/site/releases/1.0.3/www/assets`, becomes `{root}/www/assets`: the alias `\MMO\filename()` resolves wherever the site runs. A target's folder stands for its releases, `current` and `shared/`, which all hold the application's root; the project's folder here stands for itself. A text file is rewritten as it is; an SQLite database (`SQLite format 3`) through its text columns, in place; any other binary file is left alone. What is left that still looks like one of these addresses afterwards is reported ([`leftovers`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/PortableContent.md#portablecontent-leftovers)): an address the declaration does not know of yet (`sync.urls`, `sync.folders`).
$portable = new PortableContent(['https://acme.com/'], ['/var/www/acme'], ['/home/me/dev/acme']); $portable->apply('{"src":"https:\/\/acme.com\/assets\/a.jpg","dir":"/var/www/acme/current/db"}'); // {"src":"assets\/a.jpg","dir":"{root}/db"}

Index

HOMEwhat the application's url alone becomes
ROOTwhat an absolute folder of the application becomes
SQLITEthe first bytes of an SQLite database
needles
patterns
rules
addUrl($url)
apply($content)
applyFile($filename)Make a file portable, in place: a text rewritten, an SQLite database through its text columns.
applySqlite($filename)
isEmpty()
IsSqlite($content) static
IsText($content) static
leftovers($content)
rule($from, $to)a replacement, and its JSON-escaped form
__construct($urls, $targetFolders, $rootFolders)

Constantes3

HOME

what the application's url alone becomes

const HOME = './'

ROOT

what an absolute folder of the application becomes

const ROOT = '{root}/'

SQLITE

the first bytes of an SQLite database

const SQLITE = 'SQLite format 3'

Propriétés3

needles

protected array $needles = []
Type
array

patterns

protected array $patterns = []
Type
array

rules

protected array $rules = []
Type
array

Méthodes10

addUrl($url)

PortableContent.php:67
protected function addUrl(string $url): void
$urlstringan url of the application: its forms with and without a scheme, raw and JSON-escaped
retournevoid

applyFile($filename)

PortableContent.php:130

Make a file portable, in place: a text rewritten, an SQLite database through its text columns.

function applyFile(string $filename): array
$filenamestring
retournearraybool, leftovers: list<string>} whether it was rewritten, and what still looks absolute

applySqlite($filename)

PortableContent.php:146
protected function applySqlite(string $filename): array
$filenamestringan SQLite database, not in use (a copy)
retournearraybool, leftovers: list<string>}

IsSqlite($content)

staticPortableContent.php:123
static function IsSqlite(string $content): bool
$contentstring
retourneboolwhether $content starts as an SQLite database

IsText($content)

staticPortableContent.php:120
static function IsText(string $content): bool
$contentstring
retourneboolwhether $content is text: no NUL byte in its first 8 KB

leftovers($content)

PortableContent.php:106
function leftovers(string $content): array
$contentstring
retournearraythe addresses of the application still in $content, with what surrounds them

__construct($urls, $targetFolders, $rootFolders)

PortableContent.php:47
function __construct(array $urls = [], array $targetFolders = [], array $rootFolders = [])
$urls = []arraythe application's urls, on every copy (its public url, this machine's)
$targetFolders = []arraya target's folders, holding releases/, current and shared/ (as declared, and their real paths)
$rootFolders = []arrayfolders that are the application's root itself (this project's folder)