Download the PHP package mootly/mp_errors without Composer

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

MoosePlum Error Management Class

This is a standalone version of the error class used by MoosePlum, for those who want a really simple in-application error logger for their PHP apps.

This is for logging errors that are internal to the application and do not, and in most cases should not, generate system errors.

[!WARNING] This is NOT a secure solution.

The error log is stored internally in an array that defaults to only storing the last 100 entries.

The class also stores an array of status messages for use in reporting. It starts with a default set that can be added to.

The primary function of this class is to standardize error logging across all objects in an application.

System Requirements

Requirements are pretty simple.

Dependencies

None.

Defaults

The default namespace for this class is 'mpc', which is short for 'MoosePlum Class'.

The default location for this class definition should be your vendor library. For inclusion with other MoosePlum stuff that would be /_lib/mootly/mp_errors/.

Assets

The files in this set are as follows:

path description
composer.json Yep, we are using Composer.
LICENSE.md License notice ( MIT ).
README.md This document.
mpt_errors.php Local unit test file to make sure things work.
src/mpc_errors.php The class definition.
src/mpi_errors.php The interface for the class.

Installation

Manual Installation

Put this class definition and any dependencies into your vendor library. For inclusion with other MoosePlum stuff that would be /_lib/mootly/mp_errors/.

Use your preferred method for including classes in your code.

Composer Installation

This class definition is listed on Packagist for installation using Composer.

See the Composer website for a directions on how to properly install Composer on your system.

Once Composer is installed and running, add the following code to the composer.json file at the root of your website.

Make sure you have the following listed as required. Adjust version numbers as necessary. See the composer.json in this class definition for required versions of dependencies for this version of the package.

If necessary for your configuration, make sure you have the following autoload definitions listed in your composer.json. Adjust the first step in the path as needed for the location of your vendor library.

In your terminal app of choice, navigate to the root of your website and run the following command. (Depending on how you installed composer, this may be different.)

This should install this class definition and any related dependencies in your vendor library and sets up composer to link them into your application.

To be safe you can also run the following to rebuild the composer autoloader and make sure your classes are correctly registered.

Make sure you have the following line to your page or application initialization code before using this class definition. Adjust accordingly based on the location of your vendor library.

That should be all your need to do to get it up and running.

Configuration

If you are using autoloading, the recommended method for instantiation is as follows:

The constructor takes three optional arguments.

  1. Status Codes (array) - An array of status codes. See the format below.
  2. Replace Flag (bool) - Whether to allow existing status codes to be replaced or not when the code is matched by a new entry. Default is false. True will override at any time.
  3. Log Size (int) - Length of status log. Default is 100.

It is recommended that you create a single class instance and load it into your other objects as a depedency. For example:

Usage

The use of namespaces or other unique identifiers to create unique strings for locking is strongly encouraged.

Examples:

Autogeneration examples:

For security add a hash of some sort that is always used for all calls by a given class. This prevents others without access to private properties from overwriting any locks. Examples of PHP hash generators:

Since these will only persist for as long as it takes for PHP to generate and send out an HTTP response, they do not need to be overly secure. There are only milliseconds to guess the hash before it is gone.

MoosePlum classes define the following property on instantiation to ensure unique names.

The Status Code Array

Status codes are stored in an array. Each array element is structured as follows:

For example, these are the predefined status codes.

The Status Log

Status messages are added to an array that is defined as follows:

The array functions as a stack so last in, first out. The most recent status code is entered at position 0.

A get() call will return the last element recorded as an array with the above values, or false if an out of range request is made.

Methods

setStatus

Add an entry to the status log. See above for the structure of the status log.

If the status log exceeds maximum size, remove the oldest element.

If a source is not specified, log as 'source not specified'.

Return false is the status code does not exist in the status code array.

getStatus

Return the most recently logged status message as an array (see above), or the one specified in the call. The most recent message has a position of 0.

Return false if asking for an out of bounds element.

getStatusCodes

Return array of all available error codes.

This method tkes no arguments.

getStatusCount

Return the number of messages in the status log.

This method takes no arguments.

addStatusCodes

Submit an array of error codes to add to the status code array.

Pass a replaces flag of true to overwrite existing codes in the case of matches.

See above for the structure of the status code array.


All versions of mp_errors with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.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 mootly/mp_errors contains the following files

Loading the files please wait ....