Download the PHP package eftec/chaosmachineone without Composer

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

ChaosMachineOne for PHP

A controlled random generator data for PHP. The objective of the library is to help generate and fill random values to memory, Mysql, Sql Server and Oracle while we could add some tendencies/biases so the values are not as fully random.

Build Status Packagist Total Downloads [Maintenance]() [composer]() [php]() [CocoaPods]()

Table of contents

What is the objective?

Sometimes we want to generate fake values for the database that are controlled and consistent. So, this library tries to create an ordered chaos.

While there are libraries to generate random values (such as fzaninotto/Faker), the objective of this library is to fill tables with random but credible/with a trend value.

Medium Article

Let's say the next exercise. We want to generate random values for a new system (sales)

If we generate random values, the chart would look like

->gen('when _index<200 then idtable.value=random(-10,10,0.2)')

Why is it so random? it is because they are random values (sic).

So, they are right, but they don't look real because there is not a trend or a natural flow of information, it is just static noise.

Then, let's generate the same value with a sine (for example, let's say that there is a cycle of sales)

->gen('when _index<200 then idtable.add=sin(0,0,10,30)')

The chart has a trend, but it is too predictable. So, let's add all factors.

->gen('when _index<200 then idtable.value=random(-10,10,0.2) and idtable.add=sin(0,0,10,30)')

While this chart is far from real, but it is not TOO RANDOM, and it has a trend.

fields

field($name,$type,$special='database',$initValue=0,$min=PHP_INT_MIN,$max=PHP_INT_MAX)

fields are our values. They could be numeric, date and string.

Examples:

gen

It generates a value using the Minilang syntaxis.

The syntaxis is as follows:

minilang

Variable Explanation Example
$var it is php global variable. $var="hi"
field it is an minilang variable. field
field.value it is the value of a column (if any) field.value="hi"
_index indicates the current index (current number of row) _index<200
20 , 20.50 its a fixed value 20,50.3
"text",'text' it is fixed string value "text",'text'
fn() its a function myfunction(value), some.myfunction()

Reserved variables

Reserved word Explanation
null null value
false false value
true true value
on 1
off 0
undef -1 (for undefined)
flip (special value). It inverts a value ON<->OFF
Used as value.flip
now returns the current timestamp (integer)
timer returns the current timestamp (integer)
interval returns the interval (in seconds) between the last change and now
fullinterval returns the interval (in seconds) between the start of the process and now
_index returns the current index (the current counter of row)
always reserved word. It is used as "when always"

Examples:

myvar = is a variable

when always set myvar.value=null
when _index<20 set myvar.value=false

Limits.

Logic

It sets the condition(s) separated by "and" or "or"

It is not allowed to use more than operator for logic. a1=20+30 is not allowed.

Range Functions (numbers)

Functions that generates a range of values

ramp($fromX, $toX, $fromY, $toY)

It generates a ramp values (lineal values)

log($startX,$startY,$scale=1)

It generates log values

->gen('when _index<200 then idtable.value=log(0,0,100)')

exp($startX,$startY,$scale=1)

It generates exponential values. The scale is for division of Y

->gen('when _index<200 then idtable.value=exp(0,0,10)')

sin($startX,$startY,$speed=1,$scale=1,$angle=null)

It generates a sinusoid values. The angle

atan($centerX,$startY,$speed=1,$scale=1)

It generates arc-tangent values

parabola($centerX,$startY,$scaleA=1,$scaleB=1,$scale=1)

It generates a parabola. It is possible to invert the parabola by changing the scaleA by negative

bell($centerX, $startY, $sigma=1, $scaleY=1)

It generates a bell values, sigma is the "wide" of the bell.

Fixed functions (numbers)

Functions that generates a single value

randomprop(...$args)

It generates a random value by using different proportions or probabilities.

randomprop(1,2,3,30,50,20)

Example:

random($from,$to,$jump=1,...$probs)

It generates a random value from $from to $to.

Optionally, you could add a probability for each segment.

random(0,100,1,10,20,70)

idtable.value=random(0,200,1,80,10,10) // values trends to stay at the bottom

idtable.value=random(0,200,1,10,80,10) // values trends to stay at the center

idtable.value=random(0,200,1,10,10,80) // values trends to stay at the top

You can also use the next name of values

name values equivalents
fakebell [10, 25, 30, 25, 10]
fakebell2 [15, 22, 26, 22, 15]
fakebell3 [5, 15, 60, 15, 5]
rightbias [5, 10, 20, 35, 30]
leftbias [30, 35, 20, 10, 5]
flat [20, 20, 20, 20, 20]
up [10, 20, 30, 40, 50]
down [50, 40, 30, 20, 10]
sine [10, 30, 10, 30, 10]

Example:

field.speed=xxxx

It sets the speed of the field. If the field has speed then it's value it's increased for each interaction.

Example:

field.accel=xxxx

It sets the acceleration of a field. If the field has acceleration then it's speed it's increased for each iteration.

Example:

field.value=xxxx

It sets the value of a field

Example:

field.getvalue

It returns the value of a field

Example:

field.valueabs

It transforms the value of a field to absolute (always positive)

Example:

field.day , field.month , field.year, field.hour, field.minute, field.weekday

It returns the current part of the date (day,month,year,hour,minute and weekday).

It is used for field of the type datetime. It is not for set the value, it is only for get the value, no matter the value. Weekday: 1= monday, 7=sunday

Month: 1 = january, 12= december

Example:

field.stop=xxxx

It sets or returns the value of a field, it also marks the speed and acceleration to zero.

field.add=xxxx

It adds a value to a field. If the field is of the type datetime, then you could add an "hour","minute" and "day"

field.concat=xxxx

It concatenates a value to a field.

field.skip=xxx

It skips a value to the next value. It is used for date.

value
hour
day
month
monday
tuesday
wednesday
thursday
friday
saturday
sunday

Arrays and texts

->setArray('arrayname',[])

It sets an array. If the array is associative, then the value is the probability of selection.

Note: arrays and variables share the same space of memory, so if we have a variable and array with the same value, then one of them will be overridden.

randomarray("arrayname",'field'=null)

it returns a random row inside the array declared with setArray(). If the array is associative then it returns a value according its probability.

If the array is a list of objects, then it returns the value of the field.

Example:

->setFormat('formatName',[])

It sets a format (template) to merge different arrays.

This function is used in tandem with randomformat()

The arrays are marked as {{name-of-the-array}}. If the array is not defined then it returns the value of a field.

If the array is associative then it returns a value according its probability.

Example:

randomformat($nameFormat)

It generates a random text using a mixes of format and different arrays.

Example:

randomtext($starting,$arrayName,$paragraph,$wordMinimum,$wordMaximum)

It generates a random text by using the array with name $arrayName. The text could start with a default text.

If $paragraph is not 0, then it could generate paragraph (line carriage)

If arrayName is empty then it uses an array with "lorem ipsum" words.

randommask($mask,$arrayName='')

It generates a text based on a mask

randommask("##-00 uu ll \0 - oo (a)","lastName") // where lastName is an array

Example:

Other Features

end

It ends the current run. It is useful when you want to stop inserting values.

Example:

omit

It omits the current loop. It is useful when you want to skip some values.

Example:

See skip to omit dates

File features

arrayFromFolder()

It reads a folder and returns an array of files. The reading is not recursive, and it could be filtered by extension.

$filesWithoutExtension=$chaos->arrayFromFolder($localfolder,'jpg',false);

Script function destionationArray.copyfilefrom()=originArray.getvalue

It copies a file from a location to another.

Database

This library allows to interact directly with the database, reading and inserting information.

For example, let's say the next exercise:

table($table, $conditions,$prefix='origin_')

It sets the working table and the number of values to process.

If you are using a database, then table is used to determine where the values will be inserted.

If you are not using a database, then table is only for reference.

The value of the query is stored in the fields called : origin_name of the column

update($table,$indexcolumn,$indexvalue,$updatecolumn1,$updatevalue1...)

Update a simple row of a table. You can update up to 3 values.

Example:

insert($storeCache=false,$echoProgress=null,$continueOnError=false,$maxRetry=3)

Insert random values into the database.

Note: This method is deprecated. Use instead setInsert()

setInsert($continueOnError=false,$maxRetry=3)

It sets to insert the values into the database. This operation is executed when the command run() is executed.

setArrayFromDBQuery($name,$query,$probability=[1],$queryParam=null)

It sets an array using a query

Note: arrays and variables share the same space of memory.

setArrayFromDBTable($name,$table,$column,$probability=[1])

It sets an array using a table

Note: arrays and variables share the same space of memory, so if you use the same name, then you can override one of them.

Examples:

Connect to Sql Server

Connect to Mysql

Generate code based in a table

Let's say that we have a table in the database called table1.

The later code will show the next values:

So you won't need to start from scratch.

This generation of code also understands foreign keys.

Insert 1000 random values

Note: Part of this code could be generated automatically.

Update all rows of a table

version

License

Dual License

LGPL-V3 and Commercial License.

Copyright Jorge Patricio Castro Castillo (2018)


All versions of chaosmachineone with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
composer/installers Version ^2.2.0
eftec/minilang Version ^2.27
ext-ctype Version *
eftec/pdoone Version 3.12.2
ext-pdo 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/chaosmachineone contains the following files

Loading the files please wait ....