Download the PHP package eftec/mapache-commons without Composer

On this page you can find all versions of the php package eftec/mapache-commons. 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 mapache-commons

Mapache Commons

It's a set of useful functions for PHP. The name is a pun (Mapache in spanish is "raccoon")

Packagist [Maintenance]() [composer]() [php]() [php]() [CocoaPods]()


Mapache Commons

Goals

It's a set of useful function with the next requirements:

Families

CollectionLib

Class CollectionLib

Method isAssoc()

Returns true if array is an associative array, false is it's an indexed array
Example:

Parameters:

Method first()

Returns the first element of an array.
Sometimes the first element is not the index [0], for example ['key1'=>1,0=2] where the first element is 'key1' and not 0. This function always returns the right value.

Parameters:

Method firstKey()

Returns the first key of an array.

Parameters:

Method arrayKeyLower()

Change the case of the key to lowercase

Parameters:

Method arrayKeyUpper()

Change the case of the key to lowercase

Parameters:

Method generateTable()

Generate a html table from an array

Parameters:

Method splitOpeningClosing()

Split a string using an opening and closing tag, by default "(" and ")".
Example:

Parameters:

Method splitNotString()

Split a string by ignoring parts of string where values are between " or '.
Example:

Parameters:

Method arrayChangeKeyCaseRecursive()

It changes the case (to lower or upper case) of the keys of an array recursively
Example:

Parameters:

Method arraySearchField()

It returns the first (or all) key(s) inside an array/object in an array that matches the value of the field
Example:

Parameters:

Method xmlToString()

It converts a xml (SimpleXMLElement object) into a string
Example:

Parameters:

Method arrayToXML()

It convers an array into a xml (SimpleXMLElement object) Example:

Parameters:

Method stringToXML()

It converts a string into a xml (SimpleXMLElement object) using simplexml_load_string including a fix
Example:

Parameters:

Method xmlToArray()

It converts an XML class (SimpleXMLElement object) into an array. Example:

Parameters:

DebugLib

Class Debug

Method var_dump()

Alternative to var_dump. It "pre" the result or it shows the result in the console of javascript.
Example:

Parameters:

Method WriteLog()

Write a log file. If the file is over 10mb then the file is resetted.

Parameters:

TextLib

Class TextLib

Method isUpper()

Returns true if the str is (completelly) uppercase

Parameters:

Method isLower()

Returns true if the str is (completelly) lowercase

Parameters:

Method between()

Obtain a string between one text and other. Example:

Parameters:

Method stripQuotes()

Strip quotes of a text " or ' if the value in between quotes
If the value is not quoted then it is not touched.
If the value is not correctly closed ("hello or "hello' ), then the quota is not removed.
The value is trimmed ' "hello world"' --> 'hello world'
Example:

Parameters:

Method removeParenthesis()

Remove the initial and final parenthesis but only if both matches.
If the $start and $end are arrays then both must have the same count and arrays are compared by pair of index
Example:

Parameters:

Method replaceBetween()

Replace the text between two needles
Example:

Parameters:

Method removeFirstChars()

Remove the first character(s) for a string
Example:

Parameters:

Method removeLastChars()

Remove the last character(s) for a string
Example:

Parameters:

Method getArgument()

It separates an argument from the value to the set value.
Returns an array with the name of the argument and value (if any). It always returns a two dimension array Example:

Parameters:

Method strPosNotSpace()

It returns the first non-space position inside a string. Example:

Parameters:

Method strposArray()

It finds the first (or last) ocurrence of a text.
Unlikely strpos(), this method allows finding more than one neddle.
Example:

Parameters:

Method parseArg()

It transforms a text = 'a1=1,a2=2' into an associative array
It uses the method parse_str() to do the conversion
Note: It doesn't work with quotes or double quotes. a1="aa,bb",bb=30 doesn't work Example:

Parameters:

Method parseArg2()

It's the same than parseArg() but it's x3 times slower.
It also considers quotes and doubles quotes.
Example:

Parameters:

Method naturalArg()

It parses a natural string and returns a declarative array
A "natural string", it is a set of values or arguments separated by space , where a value is the index and the new one is the value of the index.

Parameters:

Method str_replace_ex()

It works as str_replace, but it also allows to limit the number of replacements.

Parameters:

Method wildCardComparison()

It compares with wildcards (*) and returns true if both strings are equals
The wildcards only works at the beginning or at the end of the string.
Example:

Parameters:

  • $text param string $text (string)
  • $textWithWildcard param string|null $textWithWildcard (string|null)

Method endsWith()

it returns true if $string ends with $endString
Example:

Parameters:

  • $string param $string ()
  • $endString param $endString ()

Method replaceCurlyVariable()

Replaces all variables defined between {{ }} by a variable inside the dictionary of values.
Example:
replaceCurlyVariable('hello={{var}}',['var'=>'world']) // hello=world
replaceCurlyVariable('hello={{var}}',['varx'=>'world']) // hello=
replaceCurlyVariable('hello={{var}}',['varx'=>'world'],true) // hello={{var}}

Parameters:

  • $string The input value. It could contain variables defined as {{namevar}} (string)
  • $values The dictionary of values. (array)
  • $notFoundThenKeep [false] If true and the value is not found, then it keeps the value. Otherwise, it is replaced by an empty value (bool)

Method addParenthesis()

It adds a parenthesis (or other symbol) at the start and end of the text. If it already has it, then it is not added.
Example:

Parameters:

  • $txt Input value. Example "hello", "(hello)" (string)
  • $start the open parenthesis, by default it's '('. (string|array)
  • $end the close parenthesis, by default it's ')'. (string|array)

Method hasParenthesis()

It returns true if the text has an open and ending parenthesis (or other symbol).
Example:

Parameters:

  • $txt Input value. Example "hello", "(hello)" (string)
  • $start the open parenthesis, by default it's '('. (string|array)
  • $end the close parenthesis, by default it's ')'. (string|array)

Method camelCase()

Retains the case minus the first letter that it's converted in lowercase
If the text contains the characters "" or " ", then the next character is uppercase
If the text does not contain any character "
" or " ", then only the first character is replaced. Example:

Parameters:

  • $txt input value (string)

FileLib

Class Files
This class has a collection of functions to interact with files and directories.

Field lastError ()

Method getDirFiles()

It gets the content (files) of a directory. It does not include other directories.

Parameters:

  • $dir The directory to scan. (string)
  • $extensions The extension to find (without dot). ['*'] means any extension. (array)
  • $recursive if true (default), then it scans the folders recursively. (bool)

Method getDirFirstFile()

It returns the first file (exclude directories) find in a directory that matches a specific extension(s)
The order of the extensions could count.
If there are two files with the same extension, then it returns the first one.

Parameters:

  • $dir The directory to scan. (string)
  • $extensions The extension to find (without dot). ['*'] means any extension. (array)
  • $sort (default false), if true then it sorts the list previous the filter. (bool)
  • $descending (default false), if true then it sorts (if enable) descending. (bool)

Method getDirFolders()

It gets the content (folders) of a directory without trailing slash. It does not include files.

Parameters:

  • $dir The directory to scan. (string)
  • $recursive if true (default), then it scans the folders recursively. (bool)

Method getExtensionPath()

It gets the extension of a file (without dot). If the file has no extension then it returns empty.

Parameters:

  • $fullPath the path to analize. (string)

Method getFileNamePath()

It gets the filename (without extension and directory)

Parameters:

  • $fullPath the path to analize. (string)

Method getBaseNamePath()

It gets the base name (filename with extension). It does not include the directory.

Parameters:

  • $fullPath the path to analize. (string)

Method getDirPath()

It gets the dir from a full path (without trailing slash)

Parameters:

  • $fullPath the path to analize. (string)

Method fixUrlSeparator()

It fixes the path by converting the slash and inverse lash into the system folder separator

Parameters:

  • $fullPath the path to analize. (string)

Method safeFileGetContent()

It gets the content of a file. It never throws an exception
In case of error, it returns the default value

Parameters:

  • $filename The filename to open. (string)
  • $use_include_path used to trigger include path search. (bool)
  • $context A valid context resource created with (null)
  • $offset The offset where the reading starts. (int)
  • $length Maximum length of data read. The default is to read until end of file is reached. (int|null)
  • $default The value to return if it is unable to open the file (null|mixed)

Method safeFilePutContent()

Write a string to a file. This operator is safe, it never throws an exception.

Parameters:

  • $filename Path to the file where to write the data. (string)
  • $data The data to write. Can be either a string, an array or a stream resource. (mixed)
  • $flag The value of flags can be any combination of the following flags, with some restrictions, joined with the binary OR (|) operator. (int)
  • $context A valid context resource created with stream_context_create. (mixed)
  • $tries The number of tries (default 3). Every try has a delay of 300ms. (int)

Method isAbsolutePath()

Returns true if the path is absolute, otherwise it returns false.
This function works in Linux and Windows (and most probably in other UNIX OS)

Parameters:

  • $fullPath The path to analize. (string)

Version list

  • 1.24
    • Fixed an exception with FileLib. It also stores every error in a field.
    • Completed README.md
    • Cleaned PHPDocs.
  • 1.23 Modified .gitattributes and .gitignore to streamline the final version.
  • 1.22 The next classes have been renamed:
    • Text (deprecated) => TextLib
    • Collection (deprecated) => CollectionLib
    • Debug (deprecated) => DebugLib
    • It is because there are a dozen of libraries who use the same name for the classes.
    • You can still use the same library without changes but for new code I suggest to use the new names.
    • [new] FileLib::getDirFirstFile()
  • 1.21 added FileLib class
    • getDirFiles()
    • getDirFolders()
    • getExtensionPath()
    • getDirPath()
    • getBaseNamePath()
    • getFileNamePath()
    • fixUrlSeparator()
    • safeFileGetContent()
    • safeFilePutContent()
    • isAbsolutePath()
  • 1.20 New methods CollectionLib::xmlToString,CollectionLib::arrayToXML,CollectionLib::stringToXML,CollectionLib::xmlToArray
  • 1.17 New Method TextLib::str_replace_ex()
  • 1.16 New methods TextLib::wildcardComparison() and TextLib::endsWith()
  • 1.15 New method TextLib::parseArg2()
  • 1.14 TextLib::camelCase() solved a small bug
  • 1.13 TextLib::replaceCurlyVariable() updated
  • 1.12
    • Collection:splitOpeningClosing added argument $includeTag
  • 1.11
    • TextLib::replaceCurlyVariable Added method
  • 1.10
    • TextLib::strPosNotSpace() added argument $charlist
  • 1.9 2019-12-09
    • TextLib::replacetext() it does not crash if the end tag is missing.
    • TextLib::replacetext() it as a new argument
  • 1.8 2019-12-04
    • TextLib::between() now allows empty $startNeedle and $endNeedle
  • 1.7 2019-12-04 new methods
    • TextLib::addParenthesis()
    • TextLib::hasParenthesis()
  • 1.6 2019-12-04 new methods
    • TextLib::parseArg()
    • TextLib::naturalArg()
    • TextLib::strposArray()
    • TextLib::camelCase()
    • TextLib::removeParenthesis()
    • CollectionLib::arrayChangeKeyCaseRecursive()
    • CollectionLib::arraySearchField()
  • 1.5 2019-03-10 new functions:
    Collection:splitOpeningClosing()
    TextLib::strPosNotSpace()
    TextLib::getArgument()
    CollectionLib::splitNotString()
  • 1.4 2019-02-16 New functions TextLib::removeFirstChars(),TextLib::removeLastChars()
  • 1.3 2019-02-16 Added new methods and Unit test.
  • 1.2 2018-10-27 Some changes in the class collection.
  • 1.0 2018-09-18 First version

License

Apache-2.0.


All versions of mapache-commons with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
ext-simplexml Version *
ext-dom Version *
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 eftec/mapache-commons contains the following files

Loading the files please wait ....