sheenazien8/konstantiq

The missing constant class in laravel
4,555
Install
composer require sheenazien8/konstantiq
Latest Version:1.0.0
PHP:^8.1
Laravel:10 · 11
License:MIT
Last Updated:Apr 29, 2026
Links: GitHub  ·  Packagist
Maintainer: sheenazien8

The missing constant class in laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads Laravel Compatibility

This is a simple package that helps you manage your constant values. The root cause of this library is that sometimes you need the status in the view or the API response, but you have more than one status. You can look at the example below.

<?php

class SomeClass 
{
    // This method returns an array of status strings
    public function pain(): array
    {
        return [
            'Pending',
            'Failed',
            'Done'
        ];
    }

    // This method returns an array of status constants from PaymentStatus
    public function healthy(): array
    {
        return PaymentStatus::all()->toArray();
    }
}

Installation

You can install the package via composer:

composer require sheenazien8/konstantiq

You can publish the config file with:

php artisan vendor:publish --tag="konstantiq-config"

Usage

php artisan make:constant PaymentStatus #it will generate class \App\Constants\PaymentStatus
<?php

namespace App\Constants;

use Sheenazien8\Konstantiq\ConstanstAbstraction;

class PaymentStatus extends ConstanstAbstraction
{
    // You can add the constants that you need
    const PENDING = 'pending';
    const DONE = 'done';
}

// Usage example
PaymentStatus::PENDING; // will return the 'pending' value
PaymentStatus::all(); // will return the all of the constants

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

399,241,428 4,660

Version History

Version Released PHP Laravel License
1.0.0 ^8.1 ^10.0||^11.0 MIT