2017 © Pedro Peláez
 

symfony-bundle native-query-from-file-builder-bundle

Bundle for execute native queries from yaml files

image

micayael/native-query-from-file-builder-bundle

Bundle for execute native queries from yaml files

  • Thursday, July 26, 2018
  • by micayael
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

NativeQueryFromFileBuilderBundle

github action sf54 github action sf6 Scrutinizer Quality Score StyleCI Packagist License Latest Stable Version Total Downloads PHP from Packagist, (*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)

  • Symfony <5.4
$ composer require micayael/native-query-from-file-builder-bundle
  • Symfony >=5.4
$ 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)

  • Symfony <5.4
$ composer require micayael/native-query-from-file-builder-bundle
  • Symfony >=5.4
$ 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)
  • Symfony 5.4

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

The Versions