Download the PHP package cstuder/myts without Composer

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

MyTS

Simple PHP package for keeping time series data in relational databases.

"For if all you have is a MySQL instance, everything looks like relational data."

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Automated tests

Overview

This library is used to store meteorolgical time series measured at weather stations for the api.existenz.ch project. It is a simple and lightweight solution for storing time series data in a relational database.

First create some locations with createLocation('locationname'), then some parameters with createParameter('parametername', 'unit').

Insert values with insertValue('locationname', 'parametername', $timestamp, $value).

Retrieve values with getValues() or getLatestValues() and you will get a \cstuder\ParseValueholder\Row filled with \cstuder\ParseValueholder\Value objects:

Setup database

The package uses a connection to a MySQL compatible database (using MyTS::MyTSMySQLFactory or MyTS::MyTSFromDSNFactory) and a timeseries name to create four tables:

The values default to to the type FLOAT, but can be changed to any other time at the time of creation with createDatabaseTables().

First create some locations with createLocation('locationname'), then some parameters with createParameter('parametername', 'unit'). Both methods accept an optional key-value array which is serialized into the database.

To update a location or parameter, simply call createLocation() or createParameter() again with the same name and updated metadata. You cannot change the name of a location or parameter.

Insert values

Insert values with insertValue('locationname', 'parametername', $timestamp, $value). The timestamp is a Unix timestamp. Location and parameter names are case sensitive. The method will return true if successful. It will throw an exception if the insertion fails (I.e. if the location or parameter doesn't exist). Set the last parameter to true fail silently and just return false.

To update a previous values, the same insertValue() method can be used.

The convenience methods insertValueObject() and insertValueRow() can be used to insert values from a Value object or a Row object respectively.

Retrieve values

Use getValues() to retrieve values from the timeseries. The method accepts optional start and end times. Filtering by locations and parameters is also available (By default unknown location or parameter names will be ignored, but this can by changed by setting the parameter $failSilenty to false).

If no location and/or parameter names are given, all locations and/or parameters respectively will be returned.

For quickly retrieving the latest values, use getLatestValues(). It accepts optional location and parameter names.

Data is returned as a \cstuder\ParseValueholder\Row which is filled by an array of \cstuder\ParseValueholder\Value objects:

Maintenance

The method deleteValuesOlderThan() indiscriminately deletes all values older than a given timestamp. Use with caution.

Limitations

Usage

Sample usage code (Runnable version in sample_usage.php)

Installation

composer require cstuder/myts

Testing

composer run test

Requires a running MySQL compatible database on localhost/127.0.0.1 with the following credentials: testuser, testpassword, testdb.

Can be overwritten by a valid DSN including username and password in the environment variable MYTS_DSN, for example:

mysql:host=localhost;port=3306;dbname=testdb;user=testuser;password=testpassword;charset=utf8

Release

See CHANGELOG.md for the release history.

  1. Add changes to the changelog.
  2. Create a new tag vX.X.X.
  3. Push.

License

MIT


All versions of myts with dependencies

PHP Build Version
Package Version
Requires cstuder/parse-valueholder Version ^0.2.1
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 cstuder/myts contains the following files

Loading the files please wait ....