madsem / klever-skeleton Goto Github PK
View Code? Open in Web Editor NEWSkeleton for Slim 3 for basic single user projects.
License: MIT License
Skeleton for Slim 3 for basic single user projects.
License: MIT License
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.