An utility component for XML usage and best practices in PHP

Overview

laminas-xml

🇷🇺 Русским гражданам

Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.

У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.

Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"

🇺🇸 To Citizens of Russia

We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.

One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.

You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

Build Status

An utility component for XML usage and best practices in PHP

Installation

You can install using:

$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

Notice that this library doesn't have any external dependencies, the usage of composer is for autoloading and standard purpose.

Laminas\Xml\Security

This is a security component to prevent XML eXternal Entity (XXE) and XML Entity Expansion (XEE) attacks on XML documents.

The XXE attack is prevented disabling the load of external entities in the libxml library used by PHP, using the function libxml_disable_entity_loader.

The XEE attack is prevented looking inside the XML document for ENTITY usage. If the XML document uses ENTITY the library throw an Exception.

We have two static methods to scan and load XML document from a string (scan) and from a file (scanFile). You can decide to get a SimpleXMLElement or DOMDocument as result, using the following use cases:

test XML; // SimpleXML use case $simplexml = XmlSecurity::scan($xml); printf ("SimpleXMLElement: %s\n", ($simplexml instanceof \SimpleXMLElement) ? 'yes' : 'no'); // DOMDocument use case $dom = new \DOMDocument('1.0'); $dom = XmlSecurity::scan($xml, $dom); printf ("DOMDocument: %s\n", ($dom instanceof \DOMDocument) ? 'yes' : 'no');">
use Laminas\Xml\Security as XmlSecurity;

$xml = <<
   
    
    
   
        
   
    test
   
    
    XML;

// SimpleXML use case
$simplexml = XmlSecurity::scan($xml);
printf ("SimpleXMLElement: %s\n", ($simplexml instanceof \SimpleXMLElement) ? 'yes' : 'no');

// DOMDocument use case
$dom = new \DOMDocument('1.0');
$dom = XmlSecurity::scan($xml, $dom);
printf ("DOMDocument: %s\n", ($dom instanceof \DOMDocument) ? 'yes' : 'no');
Comments
  • PHP 8.2 Support

    PHP 8.2 Support

    Feature Request

    I'm testing an RC release of PHP 8.2, but this package fails to install due to version restrictions in composer.json. I would welcome the addition of PHP 8.2 to to the list of supported PHP versions.

    | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no

    Summary

    Hello, I understand that this package is security-only and feature-complete. However - does that mean no support for future PHP versions is coming?

    What about adding a benevolent version constaraint? That would allow us to install the package, and, if issues do occur, the community could provide MRs. That would reduce the amount of work needed for the maintainers ofthis package to minimum.

    Enhancement 
    opened by dakujem 8
  • PHP 8.1 Support

    PHP 8.1 Support

    Hello. I stumbled upon being unable to run app with this package in PHP 8.1 environment.

    This is what I get from Composer.

    - laminas/laminas-xml[1.3.0, ..., 1.4.x-dev] require php ^7.3 || ~8.0.0 -> your php version (8.1.0) does not satisfy that requirement.
    

    The issue is that the constraint in composer.json is as follows:

        "require": {
            "php": "^7.3 || ~8.0.0",
            "laminas/laminas-zendframework-bridge": "^1.0"
        },
    

    (seen here)

    I suggest changing "php": "^7.3 || ~8.0.0", to "php": "^7.3 || ^8.0", to support future versions of PHP.

    Enhancement Help Wanted 
    opened by dakujem 7
  • Add a small PHP 8.0 fix

    Add a small PHP 8.0 fix

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | yes | BC Break | no | New Feature | no | RFC | no | QA | no

    Description

    I'm updating logic so that it does not get used on PHP 8.0+. In PHP 8.0 and later, PHP uses libxml versions from 2.9.0, which disabled XXE by default. libxml_disable_entity_loader() is now deprecated.

    The current code will throw deprecation warnings/errors and break the code. As for as far as I understand it, it the same logic as it is now disabled by default so changing this value is not needed. And also reverting the change back to its original value.

    I have opted to wrap the function calls in an if statement that checks if the current PHP version is lower than PHP 8.0. This was the easiest way I could think of to update this code without touching too much of its current behavior.

    I'm not entirely sure if this is (already) wanted, this has been tested on the latest PHP 8.0 release candidate as of today.

    Also, please do let me know if you have feedback!

    EDIT:

    Please note that I did not check any other part of the code, I just noticed this when running a project on PHP 8 as a test and came across this code hit on some its pages.

    Enhancement 
    opened by xvilo 6
  • Adds support for PHP 8.1

    Adds support for PHP 8.1

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | no | BC Break | no | New Feature | yes | RFC | no | QA | no

    Description

    added PHP 8.1 support

    Enhancement 
    opened by tobias-trozowski 3
  • Set the PHP platform version for composer

    Set the PHP platform version for composer

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | no | BC Break | no | New Feature | no | RFC | no | QA | yes

    Description

    It wasn't until immediately after https://github.com/laminas/laminas-xml/pull/13 got merged that I realised we will also need the PHP version setting in composer.json to tell renovate which PHP version to run.

    Enhancement 
    opened by internalsystemerror 1
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • composer.json (composer)
    • .github/workflows/auto-close.yml (github-actions)
    • .github/workflows/continuous-integration.yml (github-actions)
    • .github/workflows/release-on-milestone-closed.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation.
    • Ignore node_modules, bower_components, vendor and various test/tests directories.
    • Automerge patch and minor upgrades if they pass tests.
    • If automerging, push the new commit directly to the base branch (no PR).
    • Wait for branch tests to pass or fail before creating the PR.
    • Rebase existing PRs any time the base branch has been updated.
    • Separate major versions of dependencies into individual branches/PRs.
    • Do not separate patch and minor upgrades into separate PRs for the same dependency.
    • Raise PR when vulnerability alerts are detected.
    • Evaluate schedules according to timezone UTC.
    • Append Signed-off-by: to signoff Git commits.
    • Apply label renovate to PRs.
    • Group all minor and patch updates together.
    • Default configuration for repositories in the Laminas organisation

    🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 3 Pull Requests:

    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: 1.5.x
    • Upgrade actions/checkout to v3
    chore(deps): update dependency laminas/laminas-coding-standard to v2
    chore(deps): lock file maintenance
    • Schedule: ["before 2am"]
    • Branch name: renovate/lock-file-maintenance
    • Merge into: 1.5.x
    • Regenerate lock files to use latest dependency versions

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 1
  • Adds ext-dom and ext-simplexml as dependencies

    Adds ext-dom and ext-simplexml as dependencies

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | yes | BC Break | no | New Feature | no | RFC | no | QA | no

    Description

    I wanted to ask this already in one of my previous PR's but forgot about it... As the extension ext-dom and ext-simplexml are required for this package to work it might be a good idea to add them.

    • added required dependencies ext-dom and ext-simplexml
    Enhancement 
    opened by tobias-trozowski 1
  • Removes the dependency to laminas-zendframework-bridge

    Removes the dependency to laminas-zendframework-bridge

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | no | BC Break | no | New Feature | yes | RFC | no | QA | no

    Description

    removed zendframework-bridge as dependency

    Enhancement 
    opened by tobias-trozowski 1
  • PHP 8.0 support

    PHP 8.0 support

    Feature Request

    | Q | A |------------ | ------ | New Feature | yes

    Summary

    To be prepared for the december release of PHP 8.0, this repository has some additional TODOs to be tested against the new major version.

    In order to make this repository compatible, one has to follow these steps:

    • [ ] Modify composer.json to provide support for PHP 8.0 by adding the constraint ~8.0.0
    • [ ] Modify composer.json to drop support for PHP less than 7.3
    • [ ] Modify composer.json to implement phpunit 9.3 which supports PHP 7.3+
    • [ ] Modify .travis.yml to ignore platform requirements when installing composer dependencies (simply add --ignore-platform-reqs to COMPOSER_ARGS env variable)
    • [ ] Modify .travis.yml to add PHP 8.0 to the matrix (NOTE: Do not allow failures as PHP 8.0 has a feature freeze since 2020-08-04!)
    • [ ] Modify source code in case there are incompatibilities with PHP 8.0
    Enhancement Help Wanted hacktoberfest-accepted 
    opened by boesing 1
  • Psalm integration

    Psalm integration

    Feature Request

    | Q | A |------------ | ------ | QA | yes

    Summary

    As decided during the Technical-Steering-Committee Meeting on August 3rd, 2020, Laminas wants to implement vimeo/psalm in all packages.

    Implementing psalm is quite easy.

    Required

    • [ ] Create a .psalm.xml.dist in the project root
    • [ ] Copy and paste the contents from this psalm.xml.dist
    • [ ] Run $ composer require vimeo/psalm
    • [ ] Run $ vendor/bin/psalm --set-baseline=psalm-baseline.xml
    • [ ] Add a composer script static-analysis with the command psalm --shepherd --stats
    • [ ] Add a new line to script: in .travis.yml: - if [[ $TEST_COVERAGE == 'true' ]]; then composer static-analysis ; fi
    • [ ] Remove phpstan from the project (phpstan.neon.dist, .travis.yml entry, composer.json require-dev and scripts)
    Optional
    • [ ] Fix as many psalm errors as possible.
    Enhancement Help Wanted hacktoberfest-accepted 
    opened by boesing 1
  • Feature: Support PHP 8.2

    Feature: Support PHP 8.2

    | Q | A |-------------- | ------ | QA | yes

    Description

    • Update composer config platform.php to 8.0.99
    • Update composer PHP to ~8.0.0 || ~8.1.0 || ~8.2.0
    • Ignore PHP platform requirements via .laminas-ci.json
    Enhancement 
    opened by ghostwriter 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    composer
    composer.json
    • php ~8.0.0 || ~8.1.0 || ~8.2.0
    github-actions
    .github/workflows/auto-close.yml
    .github/workflows/continuous-integration.yml
    .github/workflows/release-on-milestone-closed.yml

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 2
Releases(1.5.0)
Owner
Laminas Project
Laminas components and MVC.
Laminas Project
🎓 Collection of useful PHP frequently asked questions, articles and best practices

PHP.earth documentation These files are available online at PHP.earth. Contributing and license We are always looking forward to see your contribution

PHP.earth 278 Dec 27, 2022
Learn to apply best practices as a PHP backend developer

PHP eCommerce Project Here are the things that this repo will cover: Object oriented programming principles and best practices Object oriented session

Muhammad Salah 0 Aug 2, 2022
A Magento 1.x module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN, Varnish, etc using best practices outlined within the HTML5 boilerplate community.

Magento Cachebuster Cachebuster is a Magento module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN,

Gordon Knoppe 129 Apr 1, 2022
Laravel boilerplate with the best development practices.

Laravel Boilerplate Introduction ?? Welcome to Laravel Init - a boilerplate for installing laravel application. It covers: One-liner shell script to s

ColoredCow 7 Dec 29, 2021
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

CakePHP 112 Feb 15, 2022
The game is implemented as an example of scalable and high load architecture combined with modern software development practices

Crossword game The game is implemented as an example of scalable and high load architecture combined with modern software development practices Exampl

Roman 56 Oct 27, 2022
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP

Lodash-PHP Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects. Lodash-PHP tr

Lodash PHP 474 Dec 31, 2022
Adds a header to every response to try and twart Google's usage of your site in it's FLoC tracking method.

Laravel No FLoC This package will add the Permissions-Policy: interest-cohort=() to try and twart Google's usage of your site in it's FLoC tracking me

Jean-Philippe Murray 11 Jul 14, 2022
Small utility library that handles metadata minification and expansion.

composer/metadata-minifier Small utility library that handles metadata minification and expansion.

Composer 134 Dec 26, 2022
Demonstration of OOP concepts and usage of Abstract class & Interfaces

Learn OOP Demonstration of OOP concepts and usage of Abstract class & Interfaces Usage clone this repo run composer install run php index.php Code str

M N Islam Shihan 3 Sep 14, 2021
m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b

m4b-tool m4b-tool is a is a wrapper for ffmpeg and mp4v2 to merge, split or and manipulate audiobook files with chapters. Although m4b-tool is designe

Andreas 798 Jan 8, 2023
Glob-like file and pattern matching utility.

Glob-like file and pattern matching utility.

Chris Kankiewicz 94 Dec 14, 2022
Get the system resources in PHP, as memory, number of CPU'S, Temperature of CPU or GPU, Operating System, Hard Disk usage, .... Works in Windows & Linux

system-resources. A class to get the hardware resources We can get CPU load, CPU/GPU temperature, free/used memory & Hard disk. Written in PHP It is a

Rafael Martin Soto 10 Oct 15, 2022
A utility package that helps inspect functions in PHP.

A utility package that helps inspect functions in PHP. This package provides some utilities for inspecting functions (callables) in PHP. You can use i

Ryan Chandler 14 May 24, 2022
Php-timer - Utility class for timing

phpunit/php-timer Utility class for timing things, factored out of PHPUnit into a stand-alone component. Installation You can add this library as a lo

Sebastian Bergmann 7.4k Jan 5, 2023
Composer Plugin for automatically including files for easing function usage in php.

Php Inc Php inc is a composer plugin for automatically including certain files into composer's autoload and autoload-dev files config. Given a set of

Krak 5 Jan 11, 2022
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Icinga 25 Sep 18, 2022
Utility that helps you switch git configurations with ease.

git-profile Utility that helps you switch git configurations with ease Preface It is possible that you have multiple git configurations. For example:

Zeeshan Ahmad 240 Jul 18, 2022