Download the PHP package meius/flag-forge without Composer

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

Flag Forge Package

Build Status codecov Codacy Badge PHP Version

Table of Contents

Overview

The meius/flag-forge package provides an intuitive API for defining and managing bitwise enumerations in PHP. By assigning power-of-two values to each flag, the package allows you to combine multiple flags using bitwise operators and efficiently check individual flags using simple methods.

Requirements

Getting Started

To get started with the meius/flag-forge package, follow the installation instructions below and check out the usage examples.

Installation

  1. Install the package via Composer:

Usage

Below is an example enum and how to work with the FlagManager.

Working with FlagManager

Database Integration Example

FlagForge can be easily integrated with a database. The following example demonstrates how to store and retrieve a flag mask using PDO.

Database Schema and Usage Example

The following section describes the chat_user table schema used to store user permissions as a bitmask, provides a few sample records, and shows an example of how to query the database to check a specific permission.

Table Schema: chat_user

Column Data Type Constraints Description
id UUID PRIMARY KEY Unique identifier for the record.
chat_id UUID FOREIGN KEY, NOT NULL Identifier of the chat.
user_id UUID FOREIGN KEY, NOT NULL Identifier of the user.
permissions UNSIGNED TINYINT NOT NULL, DEFAULT (17) Bitmask representing user permissions.

Sample Records

Below are a few example rows inserted into the chat_user table:

id chat_id user_id permissions
11111111-1111-1111-1111-111111111111 chat-1234 user-1234 21
22222222-2222-2222-2222-222222222222 chat-1234 user-5678 23
33333333-3333-3333-3333-333333333333 chat-4321 user-9876 5

Example Query: Checking a Specific Permission

Suppose you want to check if a specific user in a chat has the "SendMessages" permission. Assume that the SendMessages permission corresponds to the bit value 1 (i.e. 1 << 0).

The following SQL query uses the bitwise AND operator to verify that the permission bit is set:

Example PHP Code Using PDO

Below is an example of how you might execute the above query using a PDO instance (assumed to be available as $pdo):

API Reference

FlagManager

Support

For support, please open an issue on the GitHub repository.

Contributing

We welcome contributions to the meius/flag-forge library. To contribute, follow these steps:

  1. Fork the Repository: Fork the repository on GitHub and clone it to your local machine.
  2. Create a Branch: Create a new branch for your feature or bugfix.
  3. Write Tests: Write tests to cover your changes.
  4. Run Tests: Ensure all tests pass by running phpunit.
  5. Submit a Pull Request: Submit a pull request with a clear description of your changes.

For more details, refer to the CONTRIBUTING.md file.

License

This package is open-sourced software licensed under the MIT license.


All versions of flag-forge with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 meius/flag-forge contains the following files

Loading the files please wait ....