Download the PHP package studiomado/query-bundle without Composer

On this page you can find all versions of the php package studiomado/query-bundle. 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 query-bundle

QueryBundle

latest stable version Latest Stable Version

2.4 (master) 2.3 2.2
Build Status Build Status Build Status
Code Coverage Code Coverage Code Coverage
Scrutinizer Code Quality Scrutinizer Code Quality Scrutinizer Code Quality

Run tests

Plain symfony project for query-bundle

The purpose of this project is to see how studiomado/query-bundle works and can be installed in a plain symfony project.

Database configuration

Remember to update parameter.yml file, parameter.yml.dist and config.yml file. In config.yml file also remember that the drive MUST be changed in pdo_sqlite to enable doctrine to work with this database.

This is just an example: for this example we use sqlite but in production you can use mysql or postgres or any other database supported by doctrine.

prompt> ./bin/console doctrine:database:create
Created database /path/to/project/var/data/data.sqlite for connection named default

Install query-bundle

prompt> composer require studiomado/query-bundle

Create at least one entity

Create at least one entity ...

prompt> ./bin/console doctrine:generate:entity

In this example I created an entity Task following command steps.

created ./src/AppBundle/Entity/
created ./src/AppBundle/Entity/Task.php
> Generating entity class src/AppBundle/Entity/Task.php: OK!
> > Generating repository class src/AppBundle/Repository/TaskRepository.php: OK!

... and update the schema ...

    prompt> ./bin/console doctrine:schema:update
    ATTENTION: This operation should not be executed in a production environment.
                         Use the incremental update to detect changes during development and use
                         the SQL DDL provided to manually update your database in production.

    The Schema-Tool would execute "1" queries to update the database.
    Please run the operation by passing one - or both - of the following options:
            doctrine:schema:update --force to execute the command
            doctrine:schema:update --dump-sql to dump the SQL statements to the screen

The schema update works only with force option

prompt> ./bin/console doctrine:schema:update --force
Updating database schema...
Database schema updated successfully! "1" query was executed

Just take a look of the database content (that now is simply empty).

prompt> ./bin/console doctrine:query:dql "select t from AppBundle:Task t"

The query will return an empty array of result

 array (size=0)
   empty

Just add first task ...

prompt> ./bin/console doctrine:query:sql "insert into task values (null, 'complete this guide', 'todo') "

and take a look of the content

prompt> ./bin/console doctrine:query:dql "select t from AppBundle:Task t"

array (size=1)
  0 =>
    object(stdClass)[507]
      public '__CLASS__' => string 'AppBundle\Entity\Task' (length=21)
      public 'id' => int 1
      public 'description' => string 'complete this guide' (length=19)
      public 'status' => string 'todo' (length=4)

Complete installation

First of all install vendors

prompt> composer require jms/serializer-bundle
prompt> composer require willdurand/hateoas-bundle
prompt> composer require white-october/pagerfanta-bundle
prompt> composer require friendsofsymfony/rest-bundle

and then, … add vendors in your app/AppKernel

new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),

Complete configuration and use the bundle

Once everything is done, you can add new endpoints using the query-bundle to query the database.

Configure your entity repository

Now be sure that your repository extends the right BaseRepository.

Customize entity serialization

Now if you want to customize responses add

use JMS\Serializer\Annotation as JMS;

On top of your entities and complete your JMS configurations. See JMS documentation to get all the complete documentation.

Here some examples:

Find All No Paginated

Added a new method in BaseRepository
When you need results applying filter and sort without pagination

This feature was needed to create an Excel Report, injecting results into the Excel Report

Example without pagination

In Controller:

Example with pagination

In Controller:

Queries

AND Conditions

If you want to create an AND condition with this library you can create it from the client for example with a simple GET request like this:

This request will produce a query like this:

OR Conditions

If you want to create an OR condition with this library you can create it from the client for example with a simple GET request like this:

This request will produce a query like this:

Instead, if you want to have more OR conditions separated you can do something like this:

This request will produce a query like this:

This can be done by using a counter after the operator separated by

Search into relations

If you want to search inside an entity where a condition is inside another entity you can do this:

This request will produce a query like this:

To do this you need to add inside the user entity some Hateoas annotations like this:

If you add Hateoas annotations correctly, you can search deeper than only "one level". Here an example:

In this example you search all users that have a profile with a country location name: Italy.
Profile, location and country are entities and name is the field.

You can use _embedded filter also into filtering_or conditions.


All versions of query-bundle with dependencies

PHP Build Version
Package Version
Requires symfony/dependency-injection Version >=3.3
symfony/config Version >=3.3
symfony/http-kernel Version >=3.3
pagerfanta/pagerfanta Version ^1.0
willdurand/hateoas Version 2.10
symfony/console Version ~3.4.3
symfony/debug Version ~3.4.3
symfony/event-dispatcher Version ~3.4.3
symfony/filesystem Version ~3.4.3
symfony/http-foundation Version ~3.4.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 studiomado/query-bundle contains the following files

Loading the files please wait ....