All Projects β†’ nahid β†’ hookr

nahid / hookr

Licence: other
PHP action and filter hook system

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to hookr

react-ui-hooks
🧩Simple repository of React hooks for building UI components
Stars: ✭ 20 (-48.72%)
Mutual labels:  hooks, hook
react-use-hoverintent
React hook for hoverIntent
Stars: ✭ 16 (-58.97%)
Mutual labels:  hooks, hook
crypto-watchdog
Crypto Watchdog is an open-source developer friendly project, periodically queries crypto market and notifies potential pumps & recently added tokens/coins via web-hooks.
Stars: ✭ 22 (-43.59%)
Mutual labels:  hooks, hook
React Nprogress
βŒ›οΈ A React primitive for building slim progress bars.
Stars: ✭ 173 (+343.59%)
Mutual labels:  hooks, hook
entangle
Global state management tool for react hooks inspired by RecoilJS and Jotai using proxies.
Stars: ✭ 26 (-33.33%)
Mutual labels:  hooks, hook
Useworker
βš›οΈ useWorker() - A React Hook for Blocking-Free Background Tasks
Stars: ✭ 2,233 (+5625.64%)
Mutual labels:  hooks, hook
use-double-tap
React hook for handling double tap on mobile devices
Stars: ✭ 18 (-53.85%)
Mutual labels:  hooks, hook
React Universal Hooks
πŸŽ‰ React Universal Hooks : just use****** everywhere (Functional or Class Component). Support React DevTools!
Stars: ✭ 148 (+279.49%)
Mutual labels:  hooks, hook
transition-hook
β˜„οΈ An extremely light-weight react transition animation hook which is simpler and easier to use than react-transition-group
Stars: ✭ 250 (+541.03%)
Mutual labels:  hooks, hook
react-use-observer
Performant react hooks for WebApi Observers, useResizeObserver, useInteractionObserver, useMutationObserver
Stars: ✭ 19 (-51.28%)
Mutual labels:  hooks, hook
React Use Wizard
πŸ§™ A React wizard (stepper) builder without the hassle, powered by hooks.
Stars: ✭ 162 (+315.38%)
Mutual labels:  hooks, hook
rusty-hook
git hook manager, geared toward Rust projects
Stars: ✭ 93 (+138.46%)
Mutual labels:  hooks, hook
Pinst
🍺 dev only postinstall hooks (package.json)
Stars: ✭ 162 (+315.38%)
Mutual labels:  hooks, hook
Fre
πŸ‘» Tiny Footprint Concurrent UI library for Fiber.
Stars: ✭ 3,195 (+8092.31%)
Mutual labels:  hooks, hook
React Intersection Observer
React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.
Stars: ✭ 2,689 (+6794.87%)
Mutual labels:  hooks, hook
use-smooth-scroll
React hook which gives a smooth scrolling function.
Stars: ✭ 41 (+5.13%)
Mutual labels:  hooks, hook
Swifthook
A library to hook methods in Swift and Objective-C.
Stars: ✭ 93 (+138.46%)
Mutual labels:  hooks, hook
Hooks
Async middleware for JavaScript and TypeScript
Stars: ✭ 117 (+200%)
Mutual labels:  hooks, hook
use-scroll-direction
A simple, performant, and cross-browser hook for detecting scroll direction in your next react app.
Stars: ✭ 24 (-38.46%)
Mutual labels:  hooks, hook
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (+351.28%)
Mutual labels:  hooks, hook

PHP hookr

A PHP package for action and filter hook. Its helps to you fire any event with your desire action. Its a similar service as WP action and filter.

Installation

Write these command from you terminal.

composer require nahid/hookr

Laravel Configuration

After complete installation go to config/app.php and add this line in providers section

Nahid\Hookr\HookrServiceProvider::class,

and add this line in aliases section

'Hook'  =>  Nahid\Hookr\Facades\Hook::class,

Thats all

Usages

Its so easy to use. Just follow the instruction and apply with your laravel project.

Action

You want to extra control with your application without touching your code you apply Action. Suppose you have a blog editor panel. Where you want add extra buttons from others developer without rewrite your code. so lets see.

<!-- post.blade.php -->
<form>
    <div class="form-group">
        <label for="title">Title</label>
        <input type="email" class="form-control" id="title" placeholder="Email">
    </div>

    <div class="form-group">
        <label for="blog">Blog</label>
        <textarea id="blog" cols="30" rows="10" class="form-control"></textarea>
    </div>

    <button type="submit" class="btn btn-default">Publish</button>
    {{hook_action('buttons')}}
</form>

Demo

See, here we use hook_action() helper function which is register as named buttons So if others developer is want to add more buttons with this form they will do this

use Nahid\Hookr\Facades\Hook;

class BlogController extends Controller
{
      public function getWritePost()
      {
          Hook::bindAction('buttons', function() {
              echo ' <button class="btn btn-info">Draft</button>';
          }, 2);
          
          return view('post');
     }
}

After run this code add new button will add with existing button.

Demo

You can also bind multiple action with this hook. Hookr also support filter. Remind this when you bind multiple filter in a hook then every filter get data from previous filters return data. Suppose you want to add a filter hook in a blog view section.

  <h1>{{$blog->title}}</h1>
  <p>
  {{hook_filter('posts', $blog->content)}}
  </p>

So we register a filter as 'posts'. Now another developer wants to support markdown for blog posts. so he can bind a filter for parse markdown.

 use Nahid\Hookr\Facades\Hook;
 
 class BlogController extends Controller
 {
       public function getPosts()
       {
           Hook::bindFilter('posts', function($data) {
               return parse_markdown($data);
           }, 2);
           
           return view('post');
      }
 }

Note: In filter, every callback function must have at least one param which is represent current data

so if you want to bind multiple data then

use Nahid\Hookr\Facades\Hook;

class BlogController extends Controller
{
     public function getPosts()
     {
         Hook::bindFilter('posts', function($data) {
             return parse_markdown($data);
         }, 2);

         Hook::bindFilter('posts', function($data) {
             return parse_bbcode($data);
         }, 3);
         
         return view('post');
    }
}

Now then given data is parse by markdown and bbcode. See, here is second param for bindFilter() is a priority for binding. Both bindAction() and bindFilter() has this feature.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].