Symfony 4 integration
konradja100 opened this issue · 4 comments
Hi, i have some issues with integration for Symfony 4.
I'm trying to install local adapter, but i can't get filesystem as a service.
I have this packages installed:
and I have this configuration in packages/knp_gaufrette.yaml
knp_gaufrette:
adapters:
foo:
local:
directory: /wamp64/www
filesystems:
bar:
adapter: foo
alias: foo_filesystem
When i try run "php bin/console gaufrette:filesystem:keys bar" i get error:
According to documentation, i should be able to access this service now by:
$container->get('knp_gaufrette.filesystem_map')->get('bar');
since Symfony 4 proper code should look like this:
$this->container->get('knp_gaufrette.filesystem_map')->get('bar');
I found a way to "override" Gaufrette services, and i can access localfilesystem by putting this configuration to services.yaml:
Gaufrette\Adapter\Local:
public: true
bind:
$directory: '/wamp64/www'
Gaufrette\Adapter:
alias: Gaufrette\Adapter\Local
Gaufrette\Filesystem:
public: true
but this way i'm not using this bundle, but Gaufrette itself.
Anyone struggle with similar issue?
Hello, can you provide the outpout of the following command please ?
bin/console debug:container | grep gaufrette
and also paste the content of your config/bundles.php
file please ?
container Gaufrette services:
and my bundles.php:
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
FOS\UserBundle\FOSUserBundle::class => ['all' => true],
JMS\I18nRoutingBundle\JMSI18nRoutingBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
Http\HttplugBundle\HttplugBundle::class => ['all' => true],
Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true],
FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true],
Sg\DatatablesBundle\SgDatatablesBundle::class => ['all' => true],
Tetranz\Select2EntityBundle\TetranzSelect2EntityBundle::class => ['all' => true],
Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],
Sentry\SentryBundle\SentryBundle::class => ['all' => true],
Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
];
As you can see container contains this services, but there is no access for them.
The gaufrette.bar_filesystem
service looks to be defined, have you tried to access it from a controller ? Is this service public?
Can you also print the App\Controller\DashboardController
class please and also the class of its container please? Have you defined your controller as a service ?
I've solved this issue by creating adapter and binding gaufrette.bar_filesystem to it:
App\Service\GaufretteAdapter:
bind:
$filesystem: '@gaufrette.bar_filesystem'
<?php
namespace App\Service;
class GaufretteAdapter
{
private $filesystem;
public function __construct($filesystem)
{
$this->filesystem = $filesystem;
}
/**
* @return mixed
*/
public function getFilesystem()
{
return $this->filesystem;
}
}
With this solution you can access filesystem by type hinting GaufretteAdapter as normal dependency.
Thanks for help!