Download the PHP package kengoldfarb/underscore_libs without Composer

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

UnderscorePHP _Libs

A set of useful, framework-agnostic PHP libraries to make life easier

http://www.underscorephp.com

Goal: A set of libraries that are useful, flexible, and can be used within any framework.

Installation

Composer

Using the composer package manager, In your composer.json file add:

Then install it (from the same directory as composer.json): php composer.phar install

Manual Installation

You can either download the latest release or you can just grab the source of an individual library and plug it in to your project.

Usage

Here you'll find information and examples about each of the libraries. These examples may not cover all permutations of how a library may be used. For more advanced details please view the source code...hopefully you'll find that the comments are very verbose and easy to understand.

Tests

Tests can be found in the 'tests' directory and can be run with phpunit. If you've cloned this repository, you can run the tests...

Logging

The logging library provides are log levels and the ability to log complex objects.

Logs are written via php's native function. The location of the log message may appear in a file, webserver log, syslog, etc. depending on your settings.

Change the error_log setting in your php.ini file to adjust the location.

Options

You can set the following options on the logger:

  • Default: DEBUG

The log level may be set to one of:

Once set, any logs at or above that level will be logged. For example, if I set the level to INFO, any 'debug' logs will not be written but a 'warn' log would be written.

  • Default: TRUE

Boolean. Whether or not to log complex objects.

  • Default: FALSE

Boolean. Whether to use php's for log messages. Can be handy for CLI scripts.

  • Default: FALSE

Boolean. Whether to throw an exception if an error log can't be written. In most cases you probably want to leave this FALSE

Examples

Encryption

The Crypt class provides AES and RSA encryption and decryption methods.

AES encryption with PKCS7 padding

Options

$textToEncrypt Required

$key Required

$cipher Optional

Default: MCRYPT_RIJNDAEL_256 Allowed values are: MCRYPT_RIJNDAEL_128, MCRYPT_RIJNDAEL_192, MCRYPT_RIJNDAEL_256

More information

$mode Optional

Default: MCRYPT_MODE_CBC Allowed values are: MCRYPT_MODE_CBC, MCRYPT_MODE_ECB, MCRYPT_MODE_CFB, MCRYPT_MODE_OFB, MCRYPT_MODE_NOFB, MCRYPT_MODE_STREAM

More information

Basic Example

RSA encryption (public/private keys)

This type of encryption is perfect for situations where you need to encrypt something within an application that doesn't need to be decrypted within the application. In that case you could keep the decryption (private) key off your application server for added security.

Generate RSA Public/Private keypair

Generate a keypair. You can optionally pass in $keybits which may be one of: 1024, 2048, 4096

RSA Encrypt/Decrypt

UUID

This library provides functions for working with a UUID or "Universally Unique Identifier".

Generate a UUID

Options

$withHyphens Default: TRUE This single option can be passed to the function that controls over whether or not the UUID will contain hyphens.

Example

Convert UUID string to binary representation

Example

Convert UUID in binary to string representation

Options

$withHyphens Default: TRUE This single option can be passed to the function that controls over whether or not the UUID will contain hyphens.

Example

Database

Wrapper for the mysqli library. Provides both regular and static class interfaces. In most cases you'll want to use the static interface which will share the DB connection within your application. This helps prevent the opening of uncessary connections.

Public variables

$mysqli For non-static interfaces, you can access the 'mysqli' object directly.

Note: the below examples assume you're using the static version of the DB class. The non-static versions of the functions have the same name without the beginning underscore. I.e. _Log::_query($sql) corresponds to $db->query($sql)

Examples

Create a connection
Create a query, escape it, get the number of rows and process the rows
Insert a new row into the db and get the resulting id

File

Simplifies the task of writing and reading from files

Regular Methods

  • writeToFile($textToWrite, $filename = NULL)
  • getFilePermissions($filename = NULL)
  • readAllFromFile($filename = NULL)
  • readByLineFromFile($filename = NULL)
  • deleteFile($filename)
  • getTemporaryFileDirectory()

Static Methods

  • _writeToFile($textToWrite, $filename, $permissions = _FileConstants::READ_WRITE_END_OF_FILE_CREATE)
  • _readAllFromFile($filename, $permission = _FileConstants::READ_ONLY)

Options

Some of the methods will allow you to pass a constant specifying which permissions the file should be opened with. The available (self explanitory) options are: _FileConstants::READ_ONLY _FileConstants::READ_WRITE _FileConstants::WRITING_ONLY_CREATE _FileConstants::READ_WRITE_TRUNCATE_CREATE _FileConstants::WRITE_ONLY_END_OF_FILE_CREATE _FileConstants::READ_WRITE_END_OF_FILE_CREATE _FileConstants::WRITE_ONLY_BEGIN_OF_FILE _FileConstants::READ_WRITE_BEGIN_OF_FILE _FileConstants::WRITE_ONLY_NO_TRUNCATE_BEGIN_OF_FILE _FileConstants::READ_WRITE_NO_TRUNCATE_BEGIN_OF_FILE

Examples

Read from file
Write to file

Info

General info and helper class.

Get the user's IP address

Gets the user's ip. This should work behind load balancers. It will first check for the header for the ip address. If that isn't set it will use .

Get the current datetime in a mysql friendly format

Random

Get Random Number

_getRand($min, $max)

Get Random String

_randString($length, $lettersNumbersOnly = false)

Get Random Character

_randCharacter($start = 32, $end = 126)

Parameters

$start The ascii character code to start from $end The ascii character code to end at

See http://www.asciitable.com for a list of character codes

Service Response

This library generates json or xml responses in a consistent format.

Parameters

$objects Any object to be serialized. String, number, object, array, etc. $echoResponse optional Whether or not to echo the response $format optional 'json' or 'xml'

Success

_success($objects, $echoResponse = TRUE, $format = 'json')

Failure

_failure($objects, $echoResponse = TRUE, $format = 'json')

SSL

TODO

Session

TODO

Web Response

TODO

Versioning

This project will follow the guidelines set forth in Semantic Versioning;

Contact

Author: Ken Goldfarb

License

MIT


All versions of underscore_libs 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 kengoldfarb/underscore_libs contains the following files

Loading the files please wait ....