micayael / native-query-from-file-builder-bundle
Bundle for execute native queries from yaml files
Installs: 4 609
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.2|^8.0
- adbario/php-dot-notation: ^2.0
- doctrine/doctrine-bundle: ^2.5
- doctrine/orm: ^2.5 || ^2.6
- symfony/config: ^5.4|^6.0
- symfony/dependency-injection: ^5.4|^6.0
- symfony/filesystem: ^5.4|^6.0
- symfony/http-kernel: ^5.4|^6.0
- symfony/yaml: ^5.4|^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.3
- phpmd/phpmd: @stable
- phpstan/phpstan: ^1.4
- symfony/framework-bundle: ^5.4|^6.0
- symfony/test-pack: ^1.0
- symfony/var-dumper: ^5.4|^6.0
README
This bundle let you write your SQL SELECT sentences into yaml files for better organization and then execute them within the application
Installation
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
- 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:
- 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.
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:
<?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:
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