Download the PHP package sri-co/plastic without Composer

On this page you can find all versions of the php package sri-co/plastic. 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 plastic

Plastic Logo

Plastic is an Elasticsearch ODM and mapper for Laravel. It renders the developer experience more enjoyable while using Elasticsearch, by providing a fluent syntax for mapping, querying, and storing eloquent models.

License Build Status StyleCI

This package is still under active development and may change.

Installing Plastic

Then we need to add the plastic service provider to config/app.php under the providers key:

Finally we need to run:

This will create a config file at config/plastic.php and a mapping directory at database/mappings.

Usage

[Defining Searchable Models]()

To get started, enable searching capabilities in your model by adding the Sleimanx2\Plastic\Searchable trait:

Defining what data to store.

By default, Plastic will store all visible properties of your model, using $model->toArray().

In addition, Plastic provides you with two ways to manually specify which attributes/relations should be stored in Elasticsearch.

1 - Providing a searchable property to our model

2 - Providing a buildDocument method

Custom elastic type name

By the default Plastic will use the model table name as the model type. You can customize it by adding a $documentType property to your model:

Custom elastic index name

By the default Plastic will use the index defined in the configuration file. You can customize in which index your model data will be stored by setting the $documentIndex property to your model:

[Storing Model Content]()

Plastic automatically syncs model data with elastic when you save or delete your model from our SQL DB, however this feature can be disabled by adding public $syncDocument = false to your model.

Its important to note that manual document update should be performed in multiple scenarios:

1 - When you perform a bulk update or delete, no Eloquent event is triggered, therefore the document data won't be synced.

2 - Plastic doesn't listen to related models events (yet), so when you update a related model's content you should consider updating the parent document.

Saving a document

Partial updating a document

Deleting a document

Saving documents in bulk

Deleting documents in bulk

[Searching Model Content]()

Plastic provides a fluent syntax to query Elasticsearch which leads to compact readable code. Lets dig into it:

To get the raw DSL query that will be executed you can call toDSL():

Pagination

You can still access the result object after pagination using the result method:

Bool Query

Nested Query

Check out this documentation of supported search queries within Plastic and how to apply unsupported queries.

Change index on the fly

To switch to a different index for a single query, simply use the index method.

[Aggregation]()

Check out this documentation of supported aggregations within plastic and how to apply unsupported aggregations.

[Suggestions]()

The suggestions query builder can also be accessed directly from the model as well:

[Model Mapping]()

Mappings are an important aspect of Elasticsearch. You can compare them to indexing in SQL databases. Mapping your models yields better and more efficient search results, and allows us to use some special query functions like nested fields and suggestions.

Generate a Model Mapping

The new mapping will be placed in your database/mappings directory.

Mapping Structure

A mapping class contains a single method map. The map method is used to map the given model fields.

Within the map method you may use the Plastic Map builder to expressively create field maps. For example, let's look at a sample mapping that creates a Tag model map:

To learn about all of the methods available on the Map builder, check out this documentation.

Run Mappings

Running the created mappings can be done using the Artisan console command:

Updating Mappings

If your update consists only of adding a new field mapping you can always update our model map with your new field and run:

The mapping for existing fields cannot be updated or deleted, so you'll need to use one of following techniques to update existing fields.

1 - Create a new index

You can always create a new Elasticsearch index and re-run the mappings. After running the mappings you can use the bulkSave method to sync your SQL data with Elasticsearch.

2 - Using aliases

Its recommended to create your Elasticsearch index with an alias to ease the process of updating your model mappings with zero downtime. To learn more check out:

https://www.elastic.co/blog/changing-mapping-with-zero-downtime

[Access The Client]()

You can access the Elasticsearch client to manage your indices and aliases as follows:

More about the official elastic client : https://github.com/elastic/elasticsearch-php

Contributing

Thank you for contributing, The contribution guide can be found Here.

License

Plastic is open-sourced software licensed under the MIT license.

To Do

Search Query Builder

Aggregation Query Builder

Mapping

General


All versions of plastic with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.4
elasticsearch/elasticsearch Version ~2.2
ongr/elasticsearch-dsl Version ~2.0
illuminate/container Version 5.2.*|5.3.*|5.4.*|5.5.*
illuminate/contracts Version 5.2.*|5.3.*|5.4.*|5.5.*
illuminate/console Version 5.2.*|5.3.*|5.4.*|5.5.*
illuminate/pagination Version 5.2.*|5.3.*|5.4.*|5.5.*
illuminate/support Version 5.2.*|5.3.*|5.4.*|5.5.*
illuminate/database Version 5.2.*|5.3.*|5.4.*|5.5.*
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 sri-co/plastic contains the following files

Loading the files please wait ....