Giter Club home page Giter Club logo

klever-skeleton's People

Contributors

madsem avatar

Watchers

 avatar  avatar

klever-skeleton's Issues

Register a class call from another library

Hi,

First, thanks for your great skeleton.

I try to add this ACL library https://github.com/JosephSilber/bouncer in your AuthMiddleware.php

I success by creating a BouncerServiceProvider and register it.

// BouncerServiceProvide.php
namespace Klever\Providers;

use League\Container\ServiceProvider\AbstractServiceProvider;
use Silber\Bouncer\Bouncer;

class BouncerServiceProvider extends AbstractServiceProvider
{
    protected $provides = [
        'bouncer',
    ];

    function register()
    {
        $this->getContainer()
             ->share('bouncer', function () {
                      return Bouncer::create();
             });
    }
}

In AuthMiddleware.php, I edit like this :

namespace Klever\Middleware;

use Bouncer;
use Illuminate\Cache\FileStore;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Cache\Repository as cacheRepository;
use Illuminate\Contracts\Cache\Repository as cacheContract;

class AuthMiddleware
{
    function __invoke($request, $response, $next)
    {
        if ( ! container()->get('auth')->verifySession()) {

            session()->flush();

            return redirect(route('auth.login'));
        }
        $acl_folder_path = base_path('storage/acl/');

        $store = new FileStore(new Filesystem, $acl_folder_path);
        $cacheRepository = new CacheContract($store);

        $bouncer = bouncer()->make()->withCache($cacheRepository)->create();
        // ok without cache : $bouncer = bouncer()->make()->create();

        $bouncer->useUserModel(User::class);

        return $next($request, $response);
    }
}

But when i want to active Bounce Cache (make()->withCache ...) i'v got this error Cannot instantiate interface Illuminate\Contracts\Cache\Repository

I try lot of things but i'm a little lost with register and cache configuration with DI league container

Could you help me please.
Thanks in advance
Rodmar

Retrieve request Attributes in ViewServiceProvider

Hi,

In the ViewServiceProvider.php file, i'm trying to add a twig global variable to store the current route name.

My code :

$routename = $this->getContainer()->get('request')->getAttribute('route')->getName();
$engine->getEnvironment()->addGlobal('current_routename', $routename);

Unfortunately Request' Attributes are always empty or null.

Could you help me please.
Thanks
Rodmar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.