PHP code example of rtroncoso / laravel-context

1. Go to this page and download the library: Download rtroncoso/laravel-context 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/ */

    

rtroncoso / laravel-context example snippets


'providers' => [
    ...
    'Cupona\Providers\ContextServiceProvider',
]

'aliases' => [
    ...
    'Cupona\Facades\Context',
]

  protected $routeMiddleware => [
      ...
      'context' => 'Cupona\Middleware\ContextMiddleware',
  ]

Route::group(['prefix' => 'admin', 'middleware' => 'context:backend', function() {
    
    // Your contextually loaded routes go here
    
}]); 

Route::group(['prefix' => 'admin', 'middleware' => 'context', 'context' => 'backend', function() {
    
    // Your contextually loaded routes go here
    
}]); 

 namespace Contextual\Providers;

use Illuminate\Support\ServiceProvider;

class BackendServiceProvider extends ServiceProvider {

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('Your\\Interfaces\\UserRepositoryInterface', 'Your\\Repositories\\Backend\\UserRepository');
        
        // Make more awesome bindings here!
    }
    
}

    Context::load('context');

    $currentContext = Context::current();