Download the PHP package mohannad/active-state without Composer

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

active-state

PHP Helper Package for marking active state in application's runtime.

Common use cases for this package includes: Marking the active menu-item, Marking the active item in your Navbar, Sidebar, or Tabs.

Total DownloadsBuild Status


Installation:

Composer:

The preferred installation method, using composer the package is available at Packagist so it can be required:

composer require mohannadnaj/active-state

Usage:

Basic:

    set_active('navbar', 'index');
    set_active('sidebar', 'info');

    is_active('navbar','index'); // return "active"
    is_active('navbar','about'); // return null

    is_active('sidebar','info'); // return "active"
    is_active('sidebar','warning'); // return null

    get_active('navbar'); // return 'index';
    get_active('sidebar'); // return 'info';

Return Custom string other than the default 'active' string:

    set_active('navbar2', 'index',['true'=>'some-active-css-class']);

    is_active('navbar2','index');    // return 'some-active-css-class'
    is_active('navbar2','about');    // return null

Return Custom string on success/failure:

    set_active('navbar3', 'register',['true'=>'is-active-css-class', 'false'=> 'not-active']);

    is_active('navbar3', 'register'); // return 'is-active-css-class'
    is_active('navbar3', 'login'); // return 'not-active'

Without Key:

    set_active('developer-mode');

    is_active('developer-mode');  // return 'active'
    is_active('not-developer-mode');  // return null

    get_active();  // return 'developer-mode'

Return Boolean:

    set_active('bottom-bar', 'index',['return'=>'boolean']); // 'boolean' or 'bool'

    is_active('bottom-bar','index');    // return true;
    is_active('bottom-bar','about');    // return false;

Get The Active Item:

    set_active('tabs', 'tab2');

    get_active('tabs'); // return 'tab2';

What's inside

Problem:

Marking an active item is a common essential part in any UI, providing a visual indication of the state of an item. This is commonly used in PHP like:

$current_page = 'contact'; 

<li class="<?= $current_page == 'home' ? 'active' : '' ?>"><a href="#home">Home</a></li>
<li class="<?= $current_page == 'about' ? 'active' : '' ?>"><a href="#about">About</a></li>
<li class="<?= $current_page == 'contact' ? 'active' : '' ?>"><a href="#contact">Contact</a></li>

Repeating this code in different parts of your application where you need to mark the active state, will make the code harder to read, harder to maintain.

Some solutions out there have the downsides: 1- Framework-Specific Package. 2- Completely based on the URL Route. 3- Only one item can be marked as active.

Solution:

The package will load the methods set_active, get_active and is_active, set_active will set a given settings to a static variable inside the Mohannadnaj\Active class, this settings answer the questions: what is the active item? what should it return if the check is passed? or should it return boolean? and what is the key you want to attach all this settings to?

The above example can be translated to:      

set_active('navbar', 'about');

<li class="<?= is_active('navbar', 'home'); ?>"><a href="#home">Home</a></li>
<li class="<?= is_active('navbar', 'about'); ?>"><a href="#about">About</a></li>
<li class="<?= is_active('navbar', 'contact'); ?>"><a href="#contact">Contact</a></li>

the set_active method will consider the first argument set_active('navbar' , ...) as a setter for the active element we want to catch later, that is 'about'.


Requirements:


Development:

Thanks for considering contributing to this project.



All versions of active-state with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
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 mohannad/active-state contains the following files

Loading the files please wait ....