All Projects → imanghafoori1 → laravel-smart-facades

imanghafoori1 / laravel-smart-facades

Licence: MIT license
Strategy design pattern in laravel, the easiest way.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-smart-facades

Laravel Qrcode Ecommerce
This is a complete laravel project that handles qrcodes, payments, api/microservices, and ecommerce
Stars: ✭ 36 (-57.14%)
Mutual labels:  laravel-framework, laravel-package
Laravel Schedulable
Schedule and unschedule eloquent models elegantly without cron jobs
Stars: ✭ 78 (-7.14%)
Mutual labels:  laravel-framework, laravel-package
Laravel Compass
A REST client inside your Laravel app
Stars: ✭ 1,002 (+1092.86%)
Mutual labels:  laravel-framework, laravel-package
Laravel Code Generator
An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.
Stars: ✭ 485 (+477.38%)
Mutual labels:  laravel-framework, laravel-package
Wagonwheel
Offer an online version of your Laravel emails to users.
Stars: ✭ 224 (+166.67%)
Mutual labels:  laravel-framework, laravel-package
Snooze
A package to simplify automating future notifications and reminders in Laravel
Stars: ✭ 515 (+513.1%)
Mutual labels:  laravel-framework, laravel-package
Laraupdater
Enable Laravel App Self-Update. Allow your Laravel Application to auto-update itself.
Stars: ✭ 75 (-10.71%)
Mutual labels:  laravel-framework, laravel-package
email-checker
Provides email verification on the go.
Stars: ✭ 116 (+38.1%)
Mutual labels:  laravel-framework, laravel-package
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (+135.71%)
Mutual labels:  laravel-framework, laravel-package
Admin One Laravel Dashboard
Admin One — Free Laravel Dashboard (Bulma Buefy Vue.js SPA)
Stars: ✭ 94 (+11.9%)
Mutual labels:  laravel-framework, laravel-package
Laravel Form Components
A set of Blade components to rapidly build forms with Tailwind CSS (v1.0 and v2.0) and Bootstrap 4. Supports validation, model binding, default values, translations, Laravel Livewire, includes default vendor styling and fully customizable!
Stars: ✭ 295 (+251.19%)
Mutual labels:  laravel-framework, laravel-package
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+3097.62%)
Mutual labels:  laravel-framework, laravel-package
csv
No description or website provided.
Stars: ✭ 47 (-44.05%)
Mutual labels:  laravel-framework, laravel-package
Laravel Open Source Projects
A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework.
Stars: ✭ 676 (+704.76%)
Mutual labels:  laravel-framework, laravel-package
Base62
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.
Stars: ✭ 16 (-80.95%)
Mutual labels:  laravel-framework, laravel-package
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-21.43%)
Mutual labels:  laravel-framework, laravel-package
laravel-crm
Free & Opensource Laravel CRM solution for SMEs and Enterprises for complete customer lifecycle management.
Stars: ✭ 927 (+1003.57%)
Mutual labels:  laravel-framework, laravel-package
artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (-33.33%)
Mutual labels:  laravel-framework, laravel-package
Dropzone Laravel Image Upload
Laravel 5.2 and Dropzone.js auto image uploads with removal links
Stars: ✭ 92 (+9.52%)
Mutual labels:  laravel-framework, laravel-package
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+173.81%)
Mutual labels:  laravel-framework, laravel-package

🍄 Laravel Smart Facades 🍄

Strategy pattern in laravel, made easy

by adding some features on top of laravel facades.

Built with ❤️ for every smart laravel developer

                                           Quality Score Code Quality Build Status Software License StyleCI

🔦 Installation:

composer require imanghafoori/laravel-smart-facades

⚡️ No need to have getFacadeAccessor()

Before:

use Illuminate\Support\Facades\Facade;

class MyFacade extends Facade
{
    protected static function getFacadeAccessor() // <--- normal facade
    {
        return 'some_key'; 
    }
}

After:

use Imanghafoori\SmartFacades\Facade;

class MyFacade extends Facade
{
    //                                          <--- smart facade
}

⚡️ Setting the default driver by shouldProxyTo($class):

Instead of bind a string to a concrete class with IOC container, you can choose the low level implementation class like this:

public function register() {              // <-- within service provider
    if ($someCondition) {
        MyFacade::shouldProxyTo( SomeDriver::class );
    } else {
        MyFacade::shouldProxyTo( SomeOtherDriver::class );
    }
}

You can proxyTo any abstract string (or closure) bound on the IoC container.

Note : If you invoke it twice, it will override:

MyFacade::shouldProxyTo( DriverClass1::class );
MyFacade::shouldProxyTo( DriverClass2::class ); // <--- This wins !

⚡️ Using Non-default Driver:

If you want to change the driver at call site:

MyFacade::withDriver(nonDefaultDriver::class)::myMethod();

⚡️ Method Hooks:

You can introduce some code "Before" and "after" a method call, remotely: (like event listeners on eloquent models)

image

Here we have told the system evenever the MyFacade::findUser($id) method was called in the system, to perform a log.

⚡️ Choosing the driver, based on parameters value:

For example, lets say you want your facade to use an SMS based driver by default, but if the text is very long (more than 200 chars) it should use an email driver.

You can do it like this:

image

🔧 Automatic method injection when calling a method through a facade.

This adds ability to enjoy automatic method injection when calling methods on POPOs (Plain Old Php Objects) WITHOUT any performance hit when you do not need it.

🐙 Example:

class Foo { ... }

class Bar
{
    // This has dependencies: "Foo", "LoggerInterface"
    public function m1 (Foo $foo, LoggerInterface $logger, string $msg)
    {
       
    }
}

Calling Bar through a Facade:

Before:

MyFacade::m1(resolve(Foo::class), resolve(LoggerInterface::class), 'hey there !'); 

After:

 // This will work and $foo, $logger would be auto-injected for us.

MyFacade::m1('hey there !');          // normal facade

// or you may want to provide some dependecies your self :
\Facades\Bar::m1(new Foo('hey man!'), 'hey there !');   //Now only the Logger is injected

🙋 Contributing:

If you find an issue, or have a better way to do something, feel free to open an issue or a pull request.

Your Stars Make Us Do More

As always if you found this package useful and you want to encourage us to maintain and work on it. Just press the star button to declare your willing.

More from the author:

Laravel Microscope

💎 Automatically find bugs before they bite.


Laravel Widgetize

💎 A minimal yet powerful package to give a better structure and caching opportunity for your laravel apps.


It's not I am smarter or something, I just stay with the problems longer.

"Albert Einstein"

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].