Download the PHP package bazarin/bazarin-php-library without Composer

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

Bazarin PHP Library - Comprehensive Guide

Bazarin PHP Library is a lightweight and efficient PHP library for database operations, file handling, API interactions, and security functions.

📌 Installation

To install the library using Composer, run:

After installation, include the autoload file in your PHP project:


Usage

1. select()

Retrieve data from a table.


2. insert()

Add new data to a table.


3. update()

Modify existing records.


4. delete()

Remove records from a table.


Error Handling

Use a try-catch block to handle exceptions:

Here's what you should add to the README file to document the RestClient and ApiManager classes:


API Library Documentation

This library provides a simple way to interact with RESTful APIs using PHP's cURL. It supports all standard HTTP methods (GET, POST, PUT, DELETE) and includes features such as custom headers, error handling, and debug logging.

Features


Installation

Simply download or clone this repository. Include the RestClient and ApiManager classes in your project.


Usage

Initialization


Methods

Fetch All Records

Fetches data using a GET request.

Create a Record

Sends a POST request to create a new resource.

Update a Record

Sends a PUT request to update an existing resource.

Delete a Record

Sends a DELETE request to remove a resource.


Advanced Features

Custom Headers

You can pass additional headers for specific requests:

Debugging Mode

Enable debug mode to log detailed information about each request and response:

Error Handling

The library automatically throws exceptions for:

Use a try-catch block to handle exceptions:


Example

The provided FileGetContent class is designed to handle incoming HTTP requests with JSON payloads and apply CORS (Cross-Origin Resource Sharing) headers to allow secure access from specified origins. Below is an explanation and usage guide for the class, which you can also include in your README file.


FileGetContent Class Documentation

Features


Methods

Constructor: __construct($origin)

Initializes the class with the allowed origin for CORS requests.


cors_auth()

Handles CORS headers to allow secure communication between origins.


get_content()

Processes the request body and decodes JSON payloads.


Example Usage

Here is an example of how to use the FileGetContent class in an API endpoint:


Notes

  1. CORS Configuration: Update the $origin parameter in the constructor to match your frontend domain. Use '*' to allow all origins (not recommended for production).
  2. Security: This class does not validate or sanitize the incoming JSON payload. Ensure that additional validation is performed as needed.

Great! The provided code uses AES-256-CBC encryption, which is a symmetric encryption method. It generates an encryption key, uses an initialization vector (IV), and supports both encryption and decryption processes. Below is the updated documentation for the Crypt class using your provided code.


Crypt Class Documentation

Overview

The Crypt class provides functionality for encrypting and decrypting data using the AES-256-CBC encryption method. The class uses a symmetric encryption system where the same key is used for both encryption and decryption. The key must be securely managed, as anyone with access to the key can decrypt the data.

Methods


1. __construct($key)

Description:

The constructor method initializes the encryption key used for both encryption and decryption.

Parameters:

Throws:

Example Usage:


2. encrypt($data)

Description:

Encrypts the provided plaintext data using AES-256-CBC encryption. The method generates a random initialization vector (IV) for encryption to enhance security.

Parameters:

Returns:

Example Usage:


3. decrypt($data)

Description:

Decrypts the provided encrypted data using the AES-256-CBC method and the same encryption key. The method extracts the IV from the base64-encoded string and uses it for decryption.

Parameters:

Returns:

Example Usage:


Important Notes

  1. Key Management: The encryption key is critical for both encrypting and decrypting data. Ensure the key is kept secure and not exposed.

  2. AES-256-CBC: This encryption method is considered very secure. It uses a 256-bit key and a 128-bit initialization vector (IV). The IV is randomly generated for each encryption operation to prevent identical data from having the same ciphertext.

  3. Initialization Vector (IV): An IV is required for AES-CBC mode. It is generated randomly for each encryption to ensure that the same plaintext encrypted multiple times produces different ciphertexts. The IV is stored alongside the ciphertext in the base64-encoded string.

  4. Base64 Encoding: The encrypted data and IV are returned as a base64-encoded string. This is done so that binary data can be safely transmitted over protocols that only support text-based data.

Example Workflow

Encryption

  1. Encrypt data using the encrypt() method:

Decryption

  1. Decrypt data using the decrypt() method:

Conclusion

The Crypt class provides an easy and secure way to encrypt and decrypt data using AES-256-CBC. The class ensures confidentiality by encrypting data with a secure algorithm and managing the initialization vector. To decrypt the data, the same key used for encryption is required.


Here is the documentation for the FileHelper class:


FileHelper Class Documentation

The FileHelper class provides utility functions for handling file uploads in PHP. It allows for uploading files to a specified destination with optional validation for file type and file size.

Methods

upload($file, $destination, $allowedTypes = [], $maxSize = 0)

This method is used to upload a file to the server. It optionally validates the file's type and size before moving it to the specified destination.

Parameters:

Return Value:

Exceptions:

The method may throw the following exceptions:


Example Usage:

In this example:


Usage Notes:


Common Errors:


Here is the documentation for the DateHelper class:


DateHelper Class Documentation

The DateHelper class provides utility functions for working with dates in PHP. It includes a method to format a date according to a specified format.

Methods

format($date, $format = 'Y-m-d')

This method is used to format a given date into a specific format.

Parameters:

Return Value:

Exceptions:


Example Usage:

In this example:


Usage Notes:


Common Errors:

Requirements


License

This project is licensed under the MIT License. See the LICENSE file for details.


All versions of bazarin-php-library with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 bazarin/bazarin-php-library contains the following files

Loading the files please wait ....