I want to disable result caching while on the development enviroment.
I do not want to comment caching codes or remove them while on dev env.
Is there any way to disable caching while on dev env?
I'm using SNCRedisBundle & Predis for Symfony2 with Redis.
Sample single result codes:
$em = $this->container->get('doctrine')->getManager();
$predis = new \Snc\RedisBundle\Doctrine\Cache\RedisCache();
$predis->setRedis(new \Predis\Client());
$qb = $em->createQueryBuilder();
$qb
->select('s')
->from('CSSliderBundle:Slider', 's')
->where($qb->expr()->eq('s.title', ':title'))
->setParameter('title', $title);
$slider = $qb
->getQuery()
->useResultCache(true, 3600 * 1.5) // added this line
->setResultCacheDriver($predis)
->setResultCacheLifetime(86400)
->getOneOrNullResult();
And second question:
Is there any way to clear cache after insert / update with doctrine build-in? I know i can use lifecycleevents but i wonder if any other option available...
Full config:
snc_redis:
clients:
default:
type: predis
alias: default
dsn: redis://localhost
logging: %kernel.debug%
options:
prefix: "%redis_prefix%"
cache:
type: predis
alias: cache
dsn: redis://localhost/1
logging: true
options:
prefix: "%redis_prefix%"
cluster:
type: predis
alias: cluster
dsn:
- redis://127.0.0.1/2
- redis://127.0.0.2/3
- redis://pw#/var/run/redis/redis-1.sock/4
- redis://127.0.0.1:6379/5
options:
profile: 2.4
connection_timeout: 10
connection_persistent: true
read_write_timeout: 30
iterable_multibulk: false
throw_errors: true
cluster: Snc\RedisBundle\Client\Predis\Connection\PredisCluster
monolog:
type: predis
alias: monolog
dsn: redis://localhost/6
logging: false
options:
connection_persistent: true
session:
client: default
use_as_default: true
doctrine:
metadata_cache:
client: cache
entity_manager: default
document_manager: default
result_cache:
client: cache
entity_manager: default
namespace: "doctrine_result_cache_%kernel.environment%_"
query_cache:
client: cache
entity_manager: default
monolog:
client: monolog
key: monolog
swiftmailer:
client: default
key: swiftmailer
You don't need to inject result cache impl to doctrine each time. Just configure your snc_redis bundle like this:
snc_redis:
# other options here..
doctrine:
result_cache:
client: cache # your redis cahce_id connection
entity_manager: default # you may specify multiple entity_managers
namespace: "doctrine_result_cache_%kernel.environment%_"
After that, you can disable it for config_dev.yml
Enable caching for $query:
// public function useResultCache($bool, $lifetime = null, $resultCacheId = null)
$query->useResultCache(true, 3600 * 1.5);
More docs: https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md#doctrine-caching
Related
Need to connect to multiple databases and followed the Symfony documentation on this matter.
I have created multiple doctrine connections and orm entity managers, and disabled autowiring.
# config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: "%env(resolve:DATABASE_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
lc_cvo:
# configure these for your database server
url: "%env(resolve:DATABASE_LC_CVO_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
lc_cvt:
# configure these for your database server
url: "%env(resolve:DATABASE_LC_CVT_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
lc_ewi:
# configure these for your database server
url: "%env(resolve:DATABASE_LC_EWI_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
lc_tbo:
# configure these for your database server
url: "%env(resolve:DATABASE_LC_TBO_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
lc_users:
# configure these for your database server
url: "%env(resolve:DATABASE_LC_USERS_URL)%"
driver: "pdo_mysql"
server_version: "5.7"
charset: utf8mb4
orm:
entity_managers:
default:
connection: default
mappings:
Main:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_lemoncake"
prefix: 'App\Entity\lmc_lemoncake'
alias: Main
lc_cvo:
connection: lc_cvo
mappings:
lc_cvo:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_lemoncake-cvo"
prefix: 'App\Entity\lmc_lemoncake_cvo'
alias: lc_cvo
lc_cvt:
connection: lc_cvt
mappings:
lc_cvt:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_lemoncake-cvt"
prefix: 'App\Entity\lmc_lemoncake_cvt'
alias: lc_cvt
lc_ewi:
connection: lc_ewi
mappings:
lc_ewi:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_lemoncake-ewi"
prefix: 'App\Entity\lmc_lemoncake_ewi'
alias: lc_ewi
lc_tbo:
connection: lc_tbo
mappings:
lc_tbo:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_lemoncake-tbo"
prefix: 'App\Entity\lmc_lemoncake_tbo'
alias: lc_tbo
lc_users:
connection: lc_users
mappings:
lc_users:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_users"
prefix: 'App\Entity\lmc_users'
alias: lc_users
My services.yaml file looks like this
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: false # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: "../src/"
exclude:
- "../src/DependencyInjection/"
- "../src/Entity/"
- "../src/Kernel.php"
- "../src/Tests/"
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: "../src/Controller/"
tags: ["controller.service_arguments"]
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Unfortunately I am receiving the following error when trying to access the login page.
Too few arguments to function App\Security\LoginFormAuthenticator::__construct(), 0 passed in /var/www/html/app/var/cache/dev/Container12fc4el/getSecurity_Firewall_Map_Context_MainService.php on line 53 and exactly 4 expected
The LoginFormAuthenticator it is referring to is listed here and needs to connect to the lc_users connection where the users' info (username, pw) is located.
I will be needing the other connections to get the client data.
class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface
{
use TargetPathTrait;
public const LOGIN_ROUTE = 'app_login';
private $entityManager;
private $urlGenerator;
private $csrfTokenManager;
private $passwordEncoder;
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder)
{
$this->entityManager = $entityManager;
$this->urlGenerator = $urlGenerator;
$this->csrfTokenManager = $csrfTokenManager;
$this->passwordEncoder = $passwordEncoder;
}
I believe I need to add something to my services so the Authenticator can retrieve the correct connection, unfortunately my knowledge on the matter is not sufficient.
I need to use multiple databases for multiple clients.
How do I fix the issue at hand?
How do I prevent this issue from occurring with the other connections?
Am I handling this in a correct way, or is there a better approach for connecting to multiple databases?
Thank you in advance for your help, feel free to ask for more info.
EDIT:
Thanks to #msg for the answer; I've managed to make it work through the following code:
app/config/services.yaml:
App\Security\LoginFormAuthenticator:
autowire: true
tags: ["doctrine.repository_service"]
arguments:
$entityManager: "#doctrine.orm.lc_users_entity_manager"
app/config/doctrine.yaml:
orm:
default_entity_manager: default
entity_managers:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
default:
...
lc_users:
connection: lc_users
mappings:
App\Entity\lmc_lemoncake:
is_bundle: false
type: annotation
dir: "%kernel.project_dir%/src/Entity/lmc_users"
prefix: 'App\Entity\lmc_users'
alias: lc_users
(part of) the getUser function of the LoginFormAuthenticator:
$em = $this->entityManager;
$repo = $em->getRepository(Users::class, 'lc_users');
$user = $repo->findOneBy(['username' => $credentials['username']]);
As already said, injecting EntityManager will get you the default one. Doctrine will register one service per manager with the name doctrine.orm.%manager_name%_entity_manager.
So if you need a different one, you have several options:
1. Explicitly configure your service to use the manager you need:
services:
App\Security\LoginFormAuthenticator:
arguments:
# Override the Manager, other arguments will be autowired.
$entityManager: '#doctrine.orm.lc_users_entity_manager'
2. Create different bindings for the different entity managers:
_defauts:
bind:
$cvoManager: '#doctrine.orm.lc_cvo_entity_manager'
$usersManager: '#doctrine.orm.lc_users_entity_manager'
# Other managers...
Based on the variable name on your dependency, the appropiate manager will be injected:
public function __construct(
EntityManagerInterface $entityManager, // Default manager
EntityManagerInterface $usersManager,
)
3. If you have many dependencies, you can also inject ManagerRegistry (the object you get in an AbstractController when you call getDoctrine()). It acts as a service locator from where you can retrieve managers or repositories:
use Doctrine\Persistence\ManagerRegistry;
public function __construct(ManagerRegistry $registry) {
$userManager = $registry->getManager('users');
}
The first option can get unwieldy fast if you have many services with different dependencies, and the third one will mask your real dependencies and complicate testing if you need to mock the registry.
I have the following Doctrine entities where EntityA is the owning side:
<?php
class EntityA
{
/**
* #ORM\ManyToOne(targetEntity="EntityB" , inversedBy="propertyA")
*/
private $propertyB;
// ....
public function setEntityB(EntityB $entBRef)
{
$this->propertyB = $entBRef;
}
}
class EntityB
{
/**
* #ORM\OneToMany(targetEntity="EntityA", mappedBy="propertyB")
*/
private $propertyA;
// ....
}
I do also have a RepositoryB class:
<?php
class RepositoryB extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
{
public function __construct(\Doctrine\Common\Persistence\ManagerRegistry $registry)
{
parent::__construct($registry, EntityB::class);
}
}
Then in my class I am trying to persist an EntityA object:
<?php
class SomeService
{
/** #var RepositoryB */
private $repositoryB;
/** #var EntityManagerInterface */
private $entityManager;
public function __construct(RepositoryB $repositoryB, EntityManagerInterface $entityManager)
{
$this->repositoryB = $repositoryB;
$this->entityManager = $entityManager;
}
public function testSomething()
{
$entBRef = $this->repositoryB->find(1);
$newEnt = (new EntityA());
$newEnt->setEntityB($entBRef);
$this->entityManager->persist($newEnt);
$this->flush();
}
}
But I've got the following error:
A new entity was found through the relationship 'EntityA#propertyB'
that was not configured to cascade persist operations for entity:
EntityB. To solve this issue: Either explicitly call
EntityManager#persist() on this unknown entity or configure cascade
Here is how my doctrine.yaml file looks like:
parameters:
env(DATABASE_URL_WRITE): ''
services:
gedmo.listener.timestampable:
class: Org\CompBundle\Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "#annotation_reader" ] ]
gedmo.listener.loggable:
class: Gedmo\Loggable\LoggableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "#annotation_reader" ] ]
gedmo.listener.deleteable:
class: Gedmo\SoftDeleteable\SoftDeleteableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ '#annotation_reader' ] ]
doctrine:
dbal:
default_connection: default
types:
microseconds: Org\CompBundle\DBAL\Types\DateTimeMicrosecondsType
connections:
read_only:
url: '%env(resolve:DATABASE_URL_READ)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
default:
url: '%env(resolve:DATABASE_URL_WRITE)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
orm:
auto_generate_proxy_classes: '%kernel.debug%'
default_entity_manager: default
entity_managers:
filters:
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
read_only:
connection: read_only
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
gedmo_loggable:
type: annotation
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
alias: GedmoLoggable
is_bundle: false
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/org/comp-bundle/Entity'
prefix: 'Org\CompBundle\Entity'
alias: Drm
dql:
datetime_functions:
timetosec: DoctrineExtensions\Query\Mysql\TimeToSec
timediff: DoctrineExtensions\Query\Mysql\TimeDiff
now: DoctrineExtensions\Query\Mysql\Now
numeric_functions:
rand: DoctrineExtensions\Query\Mysql\Rand
default:
connection: default
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
gedmo_loggable:
type: annotation
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
alias: GedmoLoggable
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/org/comp-bundle/Entity'
prefix: 'Org\CompBundle\Entity'
alias: Drm
dql:
datetime_functions:
timetosec: DoctrineExtensions\Query\Mysql\TimeToSec
timediff: DoctrineExtensions\Query\Mysql\TimeDiff
now: DoctrineExtensions\Query\Mysql\Now
numeric_functions:
rand: DoctrineExtensions\Query\Mysql\Rand
Last but not least I do have the following setup at org\compbundle\Resources\services.yaml:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
bind:
$logger: '#Psr\Log\LoggerInterface'
Org\CompBundle\Repository\:
resource: '../../Repository/{Case,Main}'
exclude: ['../../Repository/**/*Interface.php']
tags: ['doctrine.repository_service']
Org\CompBundle\Interfaces\Queues\QueueRepositoryInterface:
class: Org\CompBundle\Repository\DrmCase\QueueRepository
Org\CompBundle\Interfaces\Cases\CasesRepositoryInterface:
class: Org\CompBundle\Repository\DrmCase\CasesRepository
Doctrine\Common\Persistence\ManagerRegistry: '#doctrine'
What I have done so far?
Read a lot of post here on SO leading to the same solution add cascade={"persist"} to the owning side which I did and I must say did not work.
Read Doctrine docs looking for mistakes on my entities definition but so far everything looks fine to me.
I did found this which is helpful but I keep questioning myself why would Doctrine tries to insert and existent entity just because of the reference? Is there any way to get this working?
I do not want the EntityB persisted nor updated, it already exists. I do want the new EntityA have a FK to an existent record in EntityB.
During the weekend a work colleague did work very hard to find out what was causing the issue and after a lot of hours debugging how Doctrine and the UoW works he found where the problem was: how Doctrine and the Repository pattern works. Let me explain a little bit.
If you check this closer and go deep inside Doctrine you will notice how the following code leads to two different entities manager:
public function __construct(RepositoryB $repositoryB, EntityManagerInterface $entityManager)
{
$this->repositoryB = $repositoryB; // spin his own EM
$this->entityManager = $entityManager; // this is a new EM object
}
So:
$entBRef = $this->repositoryB->find(1);
Is being fetched through another EM and since I am using $this->entityManager to persist/flush the recently created entityA object then Doctrine sees $entBRef as a new entity that has to be persisted.
Our solution was to fetch everything through the same repository class which I do not like so much because we are querying things that does not belongs there and we had to ever persist/flush using the same EM.
If you have any other solution it is more than welcome.
I'm working with multiple Entity Managers, followed Symfony doc from here,
but I want to use two entity manager for one dir.
It's not working properly in findAll or findOneBy query, it's showing the result for 'default' entity manager.
in config/packages/doctrine.yaml :
dbal:
# configure these for your database server
default_connection: default
connections:
default:
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(DATABASE_URL)%'
blog:
driver: 'pdo_mysql'
server_version: '5.7'
url: '%env(DATABASE_BLOG_URL)%'
charset: utf8mb4
orm:
auto_generate_proxy_classes: true
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
Main:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: Main
blog:
connection: blog
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
blog:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: blog
in controller:
$entityManager = $this->getDoctrine()->getManager('blog');
$University = $entityManager->getRepository(University::class)
->findOneBy(array('Code' => $Code));
i would recommend inject the connection as a service in your Controller and leverage autowiring
//CONTROLLER
public function testController(YourService $service){
return $service->test();
}
//services.yml
App\Service\YourService:
public: true
arguments: ['#doctrine.orm.entity_manager','#doctrine.orm.blog']
//src/service/YourService.php
class YourService {
private $blog,$em;
public function __construct(EntityManager $em, EntityManager $blog) {
$this->em = $em
$this->blog = $blog;
}
public function test()
{
//connect to blog
$this->blog->getRepository(your_entity::class)->findAll();
//connect to default
$this->em->getRepository(your_entity::class)->findAll();
}
Are you trying to put the name of your second DB in the second argument of the function getRepository, like this:
$University = $entityManager->getRepository(University::class, 'blog')
->findOneBy(array('Code' => $Code));
Update 2:
Use only this configuration, without specify dir, but by using this, you will obligate to use the vanilla SQL to intercate with your DB:
blog:
connection: blog
naming_strategy: doctrine.orm.naming_strategy.underscore
my last suggestion will be to create differente folders Entities for each connection, and duplicate in it the sames entities, and like this you can use the ORM DOCTRINE properly.
In a Symfony 4 application I have configured multiple entity managers.
I want my functional tests to automatically create DB tables for both managers.
However, when I run my test; PHP unit encounters an error that says
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
Table 'test.example' doesn't exist
config/packages/doctrine.yaml:
doctrine:
dbal:
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
custom:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
orm:
default_entity_manager: default
auto_generate_proxy_classes: '%kernel.debug%'
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
Model:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Model'
prefix: 'App\Entity\Model'
alias: Model
custom:
connection: custom
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
Custom:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Custom'
prefix: 'App\Entity\Custom'
alias: Custom
To create tables and load Fixtures I'm currently using the Liip Functional Test Bundle.
A simple test looks like this:
tests\Functional\GeneralControllerTest.php:
class GeneralControllerTest extends WebTestCase
{
/**
* {#inheritdoc}
*/
protected function setUp()
{
$this->loadFixtures([
SomeFixtures::class,
MoreFixtures::class,
]);
}
/**
* #dataProvider providePageUris
* #test
* #param string $uri
*/
public function checkThatPageLoads($uri)
{
$client = static::createClient();
/* ... more code ... */
$client->request(Request::METHOD_GET, $uri);
static::assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
}
/**
* #return array
*/
public function providePageUris()
{
return [
["/dashboard"],
];
}
}
How can I make my Test Case create database tables for the other custom Doctrine EntityManagers?
I have tried adding:
$this->loadFixtures([], true, "custom");
and also:
$this->runCommand("doctrine:schema:create --env=test --em=custom");
to the setUp() method of the Test Case, but this did not result in what is needed. The database tables all need to be created before any Fixture is loaded into the database.
To not have tables in a different entity manager and connection removed when loading data fixtures I changed the doctrine configuration with distinct environment variables.
config/packages/doctrine.yaml:
doctrine:
dbal:
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
custom:
url: '%env(resolve:DATABASE_URL_CUSTOM)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
According to the code for the WebTestCase on GitHub the second argument should contain the name of the object manager. I am not sure if specifying custom is enough or if you have to specify the full name doctrine.entity_manager.custom though.
I am new to Symfony and I am jumping into the deep end with OroCommerce. I thought I had successfully setup SncRedis (solely based on the fact that the app quit throwing errors at me). However, now that the app is completely setup and installed, I can see that file-based cache is still being generated.
I have a config.yml in place as well as a config_prod.yml but it seems that config_prod.yml only extends the config.yml so I don't think there are any conflicts in config_prod.yml.
# config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: en }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: "%kernel.debug%"
form: true
csrf_protection: true
validation: { enable_annotations: true }
templating:
engines: ['twig', 'php']
assets_version: %assets_version%
assets_version_format: %%s?version=%%s
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments:
enabled: true
path: /_fragment # used for controller action in template
serializer:
enabled: true
annotations:
cache: oro.cache.annotations
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
exception_controller: "FOS\RestBundle\Controller\ExceptionController::showAction"
globals:
bap:
layout: ::base.html.twig # default layout across all Oro bundles
# Assetic Configuration
assetic:
debug: false
use_controller: false
filters:
cssrewrite: ~
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
paths: ["%kernel.root_dir%/../web/bundles"]
cssmin:
file: %kernel.root_dir%/Resources/php/cssmin-v3.0.1.php
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
encryption: "%mailer_encryption%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_rest:
body_listener:
decoders:
json: fos_rest.decoder.json
view:
failed_validation: HTTP_BAD_REQUEST
default_engine: php
formats:
json: true
xml: false
format_listener:
rules:
- { path: '^/api/rest', priorities: [ json ], fallback_format: json, prefer_extension: false }
- { path: '^/api/soap', stop: true }
- { path: '^/', stop: true }
routing_loader:
default_format: json
fos_js_routing:
routes_to_expose: [oro_*]
oro_frontend:
routes_to_expose: [oro_*]
stof_doctrine_extensions:
default_locale: en
translation_fallback: true
orm:
default:
translatable: true
tree: true
services:
twig.extension.intl:
class: Twig_Extensions_Extension_Intl
tags:
- { name: twig.extension }
oro.cache.abstract:
abstract: true
class: Snc\RedisBundle\Doctrine\Cache\RedisCache
calls:
- [setRedis, ["#snc_redis.default"]]
oro.cache.annotations:
public: false
parent: oro.cache.abstract
calls:
- [ setNamespace, [ "oro_annotations_cache" ] ]
escape_wsse_authentication:
authentication_provider_class: Oro\Bundle\UserBundle\Security\WsseAuthProvider
genemu_form:
select2: ~
autocomplete: ~
a2lix_translation_form:
locales: [en, fr]
templating: "OroUIBundle:Form:translatable.html.twig"
lexik_maintenance:
authorized:
path: "maintenance|.*\.js" # "maintenance" is only for demo purposes, remove in production!
# ips: ["127.0.0.1"] # Optional. Authorized ip addresses
driver:
class: Lexik\Bundle\MaintenanceBundle\Drivers\FileDriver
options:
file_path: %kernel.root_dir%/cache/maintenance_lock
#
# ORO Bundles config
#
oro_distribution:
entry_point: ~
oro_require_js:
build_path: "js/oro.min.js"
building_timeout: 3600
build:
preserveLicenseComments: true
oro_help:
defaults:
server: http://help.orocrm.com/
prefix: Third_Party
vendors:
Oro:
prefix: ~
alias: Platform
routes:
oro_default:
uri: Platform/OroDashboardBundle
oro_theme:
active_theme: oro
oro_message_queue:
transport:
default: '%message_queue_transport%'
'%message_queue_transport%': '%message_queue_transport_config%'
client: ~
snc_redis:
clients:
default:
type: predis
alias: default
dsn: redis://redis-session
logging: %kernel.debug%
session:
type: predis
alias: session
dsn: redis://redis-session/4
logging: %kernel.debug%
cache:
type: predis
alias: cache
dsn: redis://redis-session/1
logging: true
profiler_storage:
type: predis
alias: profiler_storage
dsn: redis://redis-session/2
logging: false
session:
client: session
prefix: session
doctrine:
metadata_cache:
client: cache
entity_manager: default
document_manager: default
result_cache:
client: cache
entity_manager: [default, read]
document_manager: [default, slave1, slave2]
namespace: "dcrc:"
query_cache:
client: cache
entity_manager: default
swiftmailer:
client: default
key: swiftmailer
doctrine:
orm:
query_cache_driver: redis
result_cache_driver: redis
jms_serializer:
metadata:
cache: Metadata\Cache\DoctrineCacheAdapter
You can install OroRedisConfigBundle that have snc/redis-bundle in dependency Instead. After that to work with redis you need to add 4 lines in parameters.yml of your application like:
session_handler: 'snc_redis.session.handler'
redis_dsn_session: 'redis://127.0.0.1:6379/0'
redis_dsn_cache: 'redis://127.0.0.1:6380/0'
redis_dsn_doctrine: 'redis://127.0.0.1:6380/1'
Don't forget to clear application cache.
And about cache folder (app/cache/prod for example). For Symfony applications it always be even if you enable redis.