Download the PHP package mbarquin/import-export-legacy without Composer

On this page you can find all versions of the php package mbarquin/import-export-legacy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package import-export-legacy

import-export-legacy

Introduction

This is a library for importing large csv or fixed-line files, it just needs an index array and a file path, the object itself is iterable, in each loop it returns an index corresponding to the read line number and an array with data in the form of the index array, if something goes wrong it returns an exception.

Installation

You can install the component in the following ways:

Usage

    $defArray = array (
        'name'    => 20,
        'surname' => 20,
        'phone'   => 10
    );

    $oImport = new mbarquin\LegacyFile\Import('./files/contacts.csv', $defArray);

    $oImport->setIsPseudoCSV(TRUE);

    foreach ($oImport as $line => $data) {
        // This is also a valid check.
        // if(is_a($data, 'Exception') === true)

        if (is_a($data, 'mbarquin\LegacyFile\ImportException') === true) {
            // Error handling
        }

    }

First of all the class needs an index definition, it's an array with the fields name as index, and in CSV case value is an integer which represents max data length, and in fixed-line cases it's the field length to be read. In this example is called defArray.

FileImport class is configured by default to read fixed-line importation files, if we want to change this behaviour we must use this method setIsPseudoCSV(TRUE|FALSE) to set CSV import file to true.

We also need a file to read, we can use an absolute or relative path, if the file not exists or something goes wrong an exception will be raised.

The object throws errors on many cases, but data size validations or fixed-line errors will not be thrown, they are returned as ImportException objects, error handling is up to you, and interrupt or not the rest of the file import, This can be configured via setReturnValidationExceptions(TRUE|FALSE) method.

    $oImport = new mbarquin\LegacyFile\Import('./files/contacts.csv', $defArray);
    $oImport->setReturnValidationExceptions(FALSE);
    try {
        foreach ($oImport as $line => $data) {

        }
    } catch(\Exception $e) {
        // Error handling.
    }

If imported file is in another encoding, the class can transcode it via iconv. Class has three encoding literals as constants, Import::UTF8 Import::LATIN1 and Import::WINDOWS_OCCI, any encoding iconv literal will be accepted as the iconv command will be encoding the text. setTranscodification($from, $to)

    $oImport = new mbarquin\LegacyFile\Import('./files/contacts.csv', $defArray);
    $oImport->setTranscodification(
        mbarquin\LegacyFile\Import::WINDOWS_OCCI, mbarquin\LegacyFile\Import::UTF8
    );

If debug mode is on, setDebug(TRUE|FALSE), Import object will track MAX memory consuption in each iteration. This library only use the memory necessary to keep the last read line from processed file. When a new line is read, the old one is deleted from memory.

This info is stored in private properties that can be accessed with:

getMaxRealMemoryUsage()
getMaxInternalMemoryUsage()

Max memory check, which writes these properties, also can be invoked with setMaxMemoryUsage() method.

If there is an environment variable called "ENV" with value "development" or "local" mode debug will be raised on construct.

Default fgetCSV separator is ; the enclosure " and scape \ , these are the defaults, they can be changed using setCsvDefaults($csvSeparator = ";", $enclosure = '"', $escape = '\'), and verified with getCsvDefaults(), which returns an array with these indexes, separator, enclosure and escape.


All versions of import-export-legacy with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mbarquin/import-export-legacy contains the following files

Loading the files please wait ...