PHP code example of watson / active

1. Go to this page and download the library: Download watson/active library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

watson / active example snippets


active()
is_active()

active(['login', 'users/*', 'posts.*', 'pages.contact']); // Returns 'active' if the current route matches any path or route name.

active(['login', 'logout'], 'active-class'); // Returns 'active-class' if the current route is 'login' or 'logout'.

active(['login', 'logout'], 'active-class', 'fallback-class'); // Returns 'fallback-class' if the current route is not 'login' or 'logout'.

<a href="{{ route('posts.index') }}" class="{{ active('posts.index') }}">All posts</a>

active(['pages/*', 'not:pages/contact'])

active(['pages.*', 'not:pages.contact'])

@if (is_active('posts/*'))
    You're looking at a blog post!
@endif

$controller = controller_name(); // foo

$action = action_name(); // bar