NativeQueryFromFileBuilderBundle
, (*1)
This bundle let you write your SQL SELECT sentences into yaml files
for better organization and then execute them within the application, (*2)
Installation
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:, (*3)
$ composer require micayael/native-query-from-file-builder-bundle
$ composer require micayael/native-query-from-file-builder-bundle:~2.0
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:, (*4)
$ composer require micayael/native-query-from-file-builder-bundle
$ composer require micayael/native-query-from-file-builder-bundle:~2.0
This command requires you to have Composer installed globally, as explained
in the installation chapter
of the Composer documentation., (*5)
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:, (*6)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Micayael\NativeQueryFromFileBuilderBundle\NativeQueryFromFileBuilderBundle(),
);
// ...
}
// ...
}
Configuration
Applications that use Symfony Flex
native_query_from_file_builder:
sql_queries_dir: '%kernel.project_dir%/config/app/queries' # optional (default: '%kernel.project_dir%/config/app/queries')
default_connection: default # see your doctrine.yaml to select the connection you want to use by default - optional default: 'default')
file_extension: yml # yaml file extension - optional (default: yaml)
cache_sql: true # caches sql statements to avoid processing yaml files in each request. Recommended for production - optional (default: true)
It is possible to define different configurations for different environments by replicating the file inside the folder corresponding to the environment or with a syntax like the following:, (*7)
native_query_from_file_builder:
default_connection: secondary_connection
cache_sql: true
when@dev:
native_query_from_file_builder:
cache_sql: false
Applications that don't use Symfony Flex
Add your configuration in app/config/config.yml, (*8)
Full Documentation and examples