PHP Classes

converter-toml: Converts files of various formats to and from TOML

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-01-29 (10 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
converter-toml 25.0.0Custom (specified...8.2Text processing, Conversion, Parsers, P...
Description 

Author

This package can convert data between JSON and TOML.

It provides scripts that call the array handler class to convert data between formats.

Currently, it provides a script to convert data between JSON and TOML formats and another script to convert data between TOML and JSON formats.

Innovation Award
PHP Programming Innovation award nominee
January 2025
Nominee
Vote
TOML is a file format used to save configuration data that is readable by humans.

This package provides example scripts to convert configuration files between TOML and JSON formats.

Manuel Lemos
Picture of ASCOOS CMS
  Performance   Level  
Name: ASCOOS CMS <contact>
Classes: 26 packages by
Country: Greece Greece
Innovation award
Innovation award
Nominee: 15x

Winner: 1x

Instructions

Require Ascoos Framework >= 25.0.0.10992

Example

<?php
/**
 * __ _ ___ ___ ___ ___ ___ ____ _ __ ___ ___
 * / _` |/ / / __/ _ \ / _ \ / / / __/| '_ ` _ \ / /
 * | (_| |\ \| (_| (_) | (_) |\ \ | (__ | | | | | |\ \
 * \__,_|/__/ \___\___/ \___/ /__/ \___\|_| |_| |_|/__/
 *
 *
 ************************************************************************************
 * @ASCOOS-NAME : ASCOOS CMS 25' *
 * @ASCOOS-VERSION : 25.0.0 *
 * @ASCOOS-CATEGORY : Framework (Frontend and Administrator Side) *
 * @ASCOOS-CREATOR : Drogidis Christos *
 * @ASCOOS-SITE : www.ascoos.com *
 * @ASCOOS-LICENSE : [Commercial] http://docs.ascoos.com/lics/ascoos/AGL.html *
 * @ASCOOS-COPYRIGHT : Copyright (c) 2007 - 2025, AlexSoft Software. *
 ************************************************************************************
 *
 * @package : ASCOOS FRAMEWORK 25'
 * @subpackage : Examples for TArrayHandler.
 * @source : Functions\convert_toml.php
 * @fileNo :
 * @version : 25.0.0
 * @build : 10992
 * @created : 2025-01-27 07:00:00 UTC+2
 * @updated :
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 * @license : AGL-F
 *
 * @since PHP 8.2.0
 */

use ASCOOS\FRAMEWORK\Kernel\Arrays\TArrayHandler;

$objArray = new TArrayHandler();

$to_format = 'JSON'; // ARRAY, JSON, OBJECT, RSS, TEXT, TOML, XML, YAML

function convert_toml(string $filename, string $to_format = 'JSON')
{
    global
$objArray;

   
$objArray->fromTOML($filename);
    return
$objArray->toFormat($to_format);
}


$data = convert_toml('config.toml');

switch (
$to_format) {
    case
'ARRAY':
        echo
var_export($data, true);
        break;

    case
'OBJECT':
        echo
var_export((array) $data, true);
        break;

    case
'RSS':
    case
'TEXT':
    case
'XML':
    case
'YAML':
    case
'JSON':
    default:
        echo
$data;
        break;
}

$objArray->Free($objArray);
?>


Details

Converter TOML

AGL-F GitHub Downloads (all assets, all releases) GitHub Release GitHub Release Date GitHub repo size Ascoos Web Extended Studio - total lines Ascoos Web Extended Studio - source code lines Ascoos Web Extended Studio - files in repository

Descript

Converts files of various formats to and from TOML data or file using the Ascoos Framework.

Requires

Require version of Ascoos Framework >= 25.0.0.10992

Example Use

<?php
use ASCOOS\FRAMEWORK\Kernel\Arrays\TArrayHandler;

function convert_toml_to_json(string $filename): string
{
  $objArray = new TArrayHandler();
  $objArray->fromTOML($filename);
  $return = $objArray->toJSON();
  $objArray->Free($objArray);

  return $return;  
}

echo convert_toml_to_json('config.toml');
?>


  Files folder image Files (6)  
File Role Description
Files folder imageClasses (1 file)
Files folder imageFunctions (3 files)
Accessible without login Plain text file LICENSE_AGL-F.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (6)  /  Classes  
File Role Description
  Accessible without login HTML file index.html Data Empty page.

  Files folder image Files (6)  /  Functions  
File Role Description
  Accessible without login Plain text file convert_toml.php Example Example script
  Accessible without login Plain text file convert_toml_to_json.php Example Example script
  Accessible without login HTML file index.html Data Empty page

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadconverter-toml-2025-01-29.zip 3KB
Downloadconverter-toml-2025-01-29.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Ascoos Framework Download .zip .tar.gz Use classes of Ascoos Framework Required
 Version Control Unique User Downloads  
 100%
Total:0
This week:0