Download the PHP package ucscode/doctrine-expression without Composer

On this page you can find all versions of the php package ucscode/doctrine-expression. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package doctrine-expression

DoctrineExpression

DoctrineExpression is a PHP library designed to facilitate cross-database compatibility when constructing SQL queries using Doctrine ORM. By abstracting database-specific syntax, developers can write more maintainable code that seamlessly adapts to different database drivers.

Table of Contents

Features

Requirements

Installation

To install Doctrine\Expression, run the following command in your terminal:

Usage

Scenario: Changing Database Drivers

Consider a scenario where your application is initially configured to use MySQL. The following configuration might be present in your Symfony .env file:

You might have a query that leverages JSON capabilities specific to MySQL:

This query works well with MySQL. However, if you decide to switch to PostgreSQL, you might change your .env configuration to:

Adapting the Query for PostgreSQL

Switching to PostgreSQL requires some modifications due to syntax differences. For example, PostgreSQL handles JSON operations differently:

Leveraging DoctrineExpression

Instead of rewriting queries for each database driver, you can utilize Doctrine\Expression to manage this complexity efficiently.

Example Usage:

The getCompatibleResult() method checks which platform is active (e.g., MySQL or PostgreSQL) and selects the corresponding query that was previously defined using defineQuery().

Providing extra Parameters to the query

You might want a set of data to be available when defining your query in a closure. For that, you can pass an array with the parameter as second argument of the Doctrine\Expression or you can call the Doctrine\Expression::set() method

Example:

For drivers that might use the same syntax, the getDefinedQuery() can be used to eliminate the need to write repetitive patterns.

Conclusion

By using Doctrine\Expression, you can maintain a clean and consistent codebase while easily adapting to changes in database platforms. This library not only saves time but also enhances collaboration among developers familiar with different SQL dialects.


Helpful Snippet for Common Use Case

How to find users by one or more roles in Symfony using Doctrine\Expression

Note:

You can handle PostgreSQL JSON/JSONB using libraries like one of the following:

The snippet below does not employ any external libraries and works without doctrine extension dependencies but only for this simple case.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Fork and send a pull request

Acknowledgments


All versions of doctrine-expression with dependencies

PHP Build Version
Package Version
Requires doctrine/orm Version ^3.2
doctrine/dbal Version ^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ucscode/doctrine-expression contains the following files

Loading the files please wait ....