Error while configuring KnpGaufretteBundle - php

I am trying to configure KnpGaufretteBundle with the help of KnpLabs
But at the point of configuring Filesystems in config.yaml I got this error
ContextErrorException: Notice: Undefined variable: adapters in
C:\xampp\htdocs\symfony2\src\Knp\Bundle\GaufretteBundle\
DependencyInjection\KnpGaufretteExtension.php
line 50
I have tried a lot to solved it.
Can any know how to remove this error or how to configure KnpGaufretteBundle Bundle in symfony 2.3.5 ?
Any help would be appreciated.

You most likely forgot to add your adapters to the bundle configuration. That's why you end up with the exception when the extension tries to setup the filesystems here ($adapters is unedefined).
Please follow the documentation Configuring the Adapters

Thanks for reply,
in my config.yml i write below code
knp_gaufrette:
adapters:
foo:
local:
directory: /path/to/my/filesystem
app/config/config.yml
knp_gaufrette:
adapters:
# ...
filesystems:
bar:
adapter: foo
alias: foo_filesystem

Thanks you all, i have made following changes and its start working...
knp_gaufrette:
adapters:
foo:
local:
directory: /path/to/my/filesystem
create: true
app/config/config.yml
knp_gaufrette:
adapters:
foo:
safe_local:
directory: /path/to/my/filesystem
create: true

Related

Doctrine insists on trying to use PostgreSQLDriver despite contrary config

I am setting up a Symfony 5.2 app, using doctrine/doctrine-bundle 2.4 and doctrine/orm 2.9. My doctrine.yaml config file looks like this:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
The problem is that when I run doctrine:fixtures:load, I get the following output:
In AbstractPostgreSQLDriver.php line 102:
An exception occurred in driver: could not find driver
In Exception.php line 18:
could not find driver
In PDOConnection.php line 39:
could not find driver
It looks like Doctrine is trying to use the Postgre driver, though I have specified MySQL. Is there another place where I need to configure this? If so, how?
===
EDIT: It looks like DATABASE_URL is not available inside my Docker container, which is probably the source of the problem. I've verified that DATABASE_URL is defined in my .env file, and that my .env file is in the same folder as my docker-compose.yml file. Also, I have a setting like this for the environment variable in that docker-compose file:
environment:
- DATABASE_URL
So I'm not quite sure what's wrong here.
I think you have a wrong DATABASE_URL in your .env file. Please check if it starts with mysql://.
I believe symfony uses dotenv package to load the values from .env to the S_ENV superglobal. You need to debug whether your dotenv (and there is a .env in your project and it is not .env.local or .env.dist) is loaded properly.
It has happened to me sometimes when I was starting, typically when cloning a Github project which has a default .env file created by Doctrine when it's installed through composer that by default Doctrine uses PostgreSQL URL.
See how many .env files have you document and I'm sure that someone overrides your URL connection.
See this StackOverflow post to know the difference between the .env.* files What is the difference between .env.local and .env.development.local

Firebase on Symfony4

I use Firebase on my Symfony application.So, I install kreait/firebase-bundle but I don't know which file I can configure this bundle on symfony4.
This configuration:
kreait_firebase:
connections:
main:
host:
secret:
references:
users:
Which file I can use this configuration??
in the documentation packagist you can configure your settup in :
config/packages/firebase.yaml
thanks :)

Unrecognized option "resource" under "fos_user"

I am integrating FOSUserBundle in my application and I am trying to run php bin/console doctrine:migration:diff after following the recommended set-up.
I am systematically getting a:
In ArrayNode.php line 319:
Unrecognized option "resource" under "fos_user"
Yet, I have set the following in my config/packages/routing.yaml:
framework:
router:
strict_requirements: ~
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
What am I doing wrong? I have "friendsofsymfony/user-bundle": "~2.0" in my composer.json and ran composer update.
Update
My fos_user.yaml is:
fos_user:
db_driver: orm
firewall_name: main
user_class: App\Entity\Admin\User
from_email:
address: no_reply#xxx.com
sender_name: xxx
Dlondero's suggestion fixed the issue, the fos_user configuration should be set in config/routes.yaml.
From documentation, routes are never automatically added in configuration.
move the :
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
into config/routes.yaml insted of confing/packages/routing.yml
If I am not wrong, config/packages/routing.yaml file is not for routes, it is the config file for routing bundle, you can not put your routing configs to there. Instead, you should put them under config/routes folder, as bundle_name.yml.
Like this, eg. config/routes/imagine.yml:
_liip_imagine:
resource: "#LiipImagineBundle/Resources/config/routing.yaml"
In my case with Symfony 4.3.2 skeleton
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
should be pasted in
config/routes/annotations.yaml
and
php bin/console debug:router
displays all the fos_user routes

Symfony3 FOSElasticaBundle doc example not working

I am trying to set up FOSElasticaBundle.
Composer json entry:
"friendsofsymfony/elastica-bundle": "^3.2"
I was following official docs tutorial, but this line doesn't work:
$finder = $this->container->get('fos_elastica.finder.app.user');
error i get:
You have requested a non-existent service "fos_elastica.index.app.user".
Do you have any idea why ?
Things i checked:
AppKernel.php contains 'new FOS\ElasticaBundle\FOSElasticaBundle(),'
Profiler under 'Configuration' tab does not show 'FOSElastica' as enabled :(
config.yml:
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
app:
types:
user:
mappings:
email: ~
persistence:
# the driver can be orm, mongodb, phpcr or propel
# listener and finder are not supported by
# propel and should be removed
driver: orm
model: AppBundle\Entity\User
provider: ~
listener: ~
finder: ~
Thanks in advance for any insights, guys :)
Turns out bundle didn't install properly.
"minimum-stability": "dev",
in composer.json on fresh installation worked

Symfony2 - Fatal error with Bundles

I've got the error [Solution at the end of the question]
Fatal error: Class 'symblog\Blogger\BlogBundle\SymblogBundle' not found in
/var/www/Symfony/app/AppKernel.php on line 20
I founded the question How to install or integrate bundles in Symfony2, but the solutions given didn't help me, because I already did what is suggested there. I'm following the tutorial symblog.co.uk except that I created at
app/config/routing.yml
a
*.php resource
Thanks in advance!
I have to add that while registering the bundle by console I've got the error
The command was not able to configure everything automatically.
You must do the following changes manually.
And the instructions:
- Edit the app/autoload.php file and register the bundle
namespace at the top of the registerNamespaces() call:
'symblog\Blogger\BlogBundle' => '/var/www/Symfony/blog',
which I followed.
AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
//..
new symblog\Blogger\BlogBundle\SymblogBundle(),
);
/app/config/routing.yml
SymblogBundle:
resource: "#SymblogBundle/Resources/config/routing.php"
prefix: /
As requested: /app/config/config.yml
imports:
- { resource: parameters.ini }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: %locale% }
secret: %secret%
charset: UTF-8
router: { resource: "%kernel.root_dir%/config/routing.yml" }
form: true
csrf_protection: true
validation: { enable_annotations: true }
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
session:
default_locale: %locale%
auto_start: true
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
# java: /usr/bin/java
filters:
cssrewrite: ~
# closure:
# jar: %kernel.root_dir%/java/compiler.jar
# yui_css:
# jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
jms_security_extra:
secure_controllers: true
secure_all_services: false
[Edit] The solution was very easy after the answer from #Clamidity that the bundles usually are located at src/Blogger/SymBlogBundle/BloggerSymBlogBundle.php
While the configuration using the console it saked about the location of the bundle and the default was /../src but I changed to /../blog. And of course it won't work, Symfony was looking into the wrong location. What I did was to move the folders inside /blog to /src and everything went fine.
There are a few things that it could be. I'll just cover anything I can think of.
Generally bundles are placed in the src folder. So the path to your bundle should look like this.
src/Blogger/SymBlogBundle/BloggerSymBlogBundle.php
(Notice that the bundle name follows the file name convention)
Inside of the BloggerSymBlogBundle.php make sure you have something similar to the following:
<?php
namespace Blogger\SymBlogBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class BloggerSymBlogBundle extends Bundle
{
}
(Notice that the same name convention is also followed here)
In your autoload.php the namespace that should be registered is the "Blogger" part of the name/path to your bundle. This is because the bundle itself resides in the Blogger folder:
'Blogger' => __DIR__.'/../src',
(Notice that the folder listed is the parent of the Blogger folder)
Now in the AppKernel.php register the bundle according the namespace your set up and registered:
new Blogger\SymBlogBundle\BloggerSymBlogBundle(),
*Note - Your resources and references to this bundle with the above configuration would be
BloggerSymBlogBundle
so your php routing would be called by using:
#BloggerSymBlogBundle/Resources/config/routing.php
There are different solution.
Clear the app/cache/(prod|dev) folder. When you have edited the Appkernel and autoload.
Fatal error: Class 'symblog\Blogger\BlogBundle\SymblogBundle' not found in
/var/www/Symfony/app/AppKernel.php on line 20
Here are now different Problems:
Look to the SymblogBundle.php in the Bundle Folder and look which namespace they use. Perhaps its really an uppercase ("S") like #kuba said.
The Class file is not in the folder or you have no rights to the folder that the interpreter can load the file.
I think your autoload.php is not correct.
'Avalanche' => __DIR__.'/../vendor/bundles',
This is the common way to register an Namespace. In your case it have to be
'Symlog' => '/var/www/Symfony/blog',
Here are the instructions from the "BloggerBundle" I hope its the correct one
There you can see the your autoload its not correct the Namespace is "Blogger".

Categories