Support the ongoing development of Laravel.io →
posted 10 years ago
Architecture
Last updated 2 years ago.
0

Why not wrap the logic in a repository class. You can still consume all your helpers and models.

Last updated 2 years ago.
0

Create your folder app/Library/Algorithms

Then in composer.json:

"autoload":{
    "classmap":[
        "app/Library"
    ],
    "psr-0":{
        "Algorithms": "app/Library"
    }
}

For example in app/Library/Algorithms you have following folders:

  • Sorting: containing IBubbleSort.php, BubbleSort.php, IQuickSort.php, QuickSort.php, SortServiceProvider.php, BubbleSortFacade.php, QuickSortFacade.php.

Each of this php files should be namespaced as Algorithms\Sorting. SortServiceProvider should use and extend \Illuminate\Support\ServiceProvider and make all bindings between interfaces and implementations.

In Facade classes extends \Illuminate\Support\Facades\Facade and implements the public static method getFacadeAccessor, ex:

class BubbleSortFacade implements \Illuminate\Support\Facades\Facade{
    public static function getFacadeAccessor(){
        return "Algorithms\Sorting\IBubbleSort"
    }
} 

Then you can add your provider to app/config.php in providers array:

'Algorithms\Sorting\SortServiceProvider'

And Facades to aliases array (in app/config.php):

'BS'     =>      'Algorithms\Sorting\BubbleSortFacade'
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

meneman meneman Joined 7 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.