Giter Club home page Giter Club logo

laravel-arangodb's Introduction

Aranguent

Github CI tests Scrutinizer Code Quality Code Coverage Latest Version Total Downloads License

ArangoDB driver for Laravel
The unguent between the ArangoDB and Laravel

The goal is to create a drop-in ArangoDB replacement for Laravel's database, migrations and model handling.

This package is in development; use at your own peril.

Installation

You may use composer to install Aranguent:

composer require laravel-freelancer-nl/aranguent

Version compatibility

Laravel ArangoDB PHP Aranguent
^8.0 and ^9.0 ^3.7 ^8.0 ^0.13
^11.0 ^3.11 ^8.2 ^1.0.0

Documentation

  1. Connect to ArangoDB: set up a connection
  2. Converting from SQL databases to ArangoDB:
  3. Migrations: migration conversion and commands
  4. Eloquent relationships: supported relationships
  5. Query Builder: supported functions
  6. Selecting JSON data: how to select subsets of documents.
  7. ArangoSearch: searching views
  8. Transactions: how to set up ArangoDB transactions
  9. FluentAQL: Use the AQL query builder directly
  10. Testing: testing your project with Aranguent.
  11. Compatibility list: overview of DB related compatible methods.
  12. Secondary database: using ArangoDB as your secondary database.

Related packages

laravel-arangodb's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar laravelfreelancernl avatar mtzonev avatar nathanromero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-arangodb's Issues

Paginate count query loses bind variables

The lengthawarepaginator executes a separate query to count the total the total number of results. However binds in the original query are lost which makes for incorrect results.

Third-party package compatibility

Aranguent is nearing the point where it can work with third party packages. I'm aiming to provide a smooth conversion with minimal extra steps for anyone implementing this driver.

If you have migrations you will need to publish and convert those.
If you have a model you will need to extend Aranguent's model or use the IsAranguentModel trait and override the key attributes (primaryKey & keyType).

These are the packages I'll be testing in the coming weeks/months:

  • ✅ Laravel Horizon
  • ✅ Spatie Medialibrary
  • ✅ Spatie Permissions
  • ✅ barryvdh/laravel-debugbar
  • ❌ Laravel Pulse
  • Laravel Passport
  • Laravel Sanctum
  • Spatie laravel-multitenancy
  • Cashier Mollie

If you have any (popular) package you'd like to see tested please put them in a comment, or better yet: help out, test it and comment your findings or help out by improving Aranguent.

Namespace ADB console commands

Move ADB specific console commands to its own namespace

See if this can be prevented by intelligently overriding Laravel commands

Booleans are cast to tinyInt in where clauses

ArangoDB speaks boolean so something like where('published', true) should be turned into FILTER doc.published == true
instead we get: FILTER doc.published == 1

This should be true by default, and configurable to tinyInt for data migrations in case someone doesn't want to change the data itself.

calling index on a field in a migration generates an indexname error

$collection->foreignId('user_id')->index();

Argument 2 passed to LaravelFreelancerNL\Aranguent\Schema\Blueprint::createIndexName() must be of the type array, bool given, called in /srv/www/lf/evesdrop/vendor/laravel-freelancer-nl/aranguent/src/Schema/Concerns/Indexes.php on line 34

Streamline schema index functions

Laravel has added support for several new index types that were already supported by this driver.

Streamline the method names to align with Laravel

Add missing drop{index-type} methods

Deprecate fulltext index functions

Test active failover

I don't have a use case for this myself. So, if you need this functionality please help out by adding tests and fixes if necessary.

Fix: Schema: no index is created for primary()

Discussed in #52

Originally posted by LaravelFreelancerNL September 20, 2021
No index is created for:
$collection->primary(['_to', '_from', 'mediable_type', 'tag']); It fails silently

Directly calling the index does work:
$collection->index(['_to', '_from', 'mediable_type', 'tag']);

Laravel Passport Install error

DB config (config/database.php)

    'connections' => [

        'arangodb' => [
            'name' => 'arangodb',
            'driver' => 'arangodb',
            'endpoint' => env('DB_ENDPOINT', 'tcp://localhost:8529'),
            'database' => env('DB_DATABASE'),
            'AuthUser' => env('DB_USERNAME'),
            'AuthPasswd' => env('DB_PASSWORD')
        ],

// ...

.env details are all correct

upon running php artisan passport:install --force

Encryption keys generated successfully.

   TypeError 

  Argument 1 passed to ArangoDBClient\Statement::__construct() must be an instance of ArangoDBClient\Connection, null given, called in .../app/vendor/laravel-freelancer-nl/aranguent/src/Connection.php on line 447

  at vendor/triagens/arangodb/lib/ArangoDBClient/Statement.php:255
    251|      *
    252|      * @param Connection $connection - the connection to be used
    253|      * @param array      $data       - statement initialization data
    254|      */
  > 255|     public function __construct(Connection $connection, array $data)
    256|     {
    257|         $this->_connection = $connection;
    258|         $this->_bindVars   = new BindVars();
    259| 

      +42 vendor frames 
  43  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Configure default key options

ArangoDB supports several key generators. The default is 'traditional', somewhat akin to the MySQL auto increment generator.

If you want to use a different one throughout your project you now have to edit each migration file.

Making the key options configurable lets a user set it for all migration files. Some commands like autoincrement and uuid on either the 'id' or '_key' field should still override the default.

Add queue driver

Add a ADB queue. The regular db queue driver uses transactions which need to be overridden.

Concerns about using _id over _key in 0.10

Hi. Thank you for your package and work.

I have some concerns about upgrading to 0.10. Particularly, in this sentence in release notes:

"Using _id is slightly slower and more verbose than using _key however provides much more third-party package compatibility out of the box."

What's your opinion about "slightly slower" and is it good for intensive load application? And would you recommend to upgrade in this case.

Also, can you please explain or guide where to start digging, from where this "slightly slower" comes. I've use two queries with _id and _key and in both keys got index scan optimization:
_key
_id

Support Laravel 11

L11 is out. Support it after the compatible testbench version is out.

Type error getTablePrefix

`php artisan model:show User

TypeError

LaravelFreelancerNL\Aranguent\Connection::getTablePrefix(): Return value must be of type string, null returned

at vendor/laravel-freelancer-nl/aranguent/src/Connection.php:115
111▕ * Get the collection prefix for the connection.
112▕ /
113▕ public function getTablePrefix(): string
114▕ {
➜ 115▕ return $this->tablePrefix;
116▕ }
117▕
118▕ /
*
119▕ * Disconnect from the underlying ArangoDB connection.

  +13 vendor frames 

14 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
`

Fully support db:wipe

The artisan db:wipe command properly drops all collections, but leaves views in place.
The same is probably true for custom analyzers.

cURL : TCP not supported

hi,

I have an error that I can't figure out how to fix it
when I launch php artisan migrate here is my error :

` ArangoClient\Exceptions\ArangoException

0 - cURL error 1: Protocol "tcp" not supported or disabled in libcurl (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for tcp://arangodb:8529/_db/laravel/_api/collection?excludeSystem=0

at E:\Test\HouseCMS\vendor\laravel-freelancer-nl\arangodb-php-client\src\ArangoClient.php:159
155▕ $code = (int) $decodedResponse->code;
156▕ }
158▕ throw(
➜ 159▕ new ArangoException(
160▕ $code . ' - ' . $message,
161▕ (int) $code
162▕ )
163▕ );

  ArangoClient\ArangoClient::handleGuzzleException()

2 E:\Test\HouseCMS\vendor\laravel-freelancer-nl\arangodb-php-client\src\Schema\ManagesCollections.php:33
ArangoClient\ArangoClient::request()`

Laravel 10 error: Create_users_table

Trying to implement arango on my new build, ran into this after installing the alpha version of aranguent (which, btw, was I supposed to do that differently? Just using the base install it threw a compatibility error, so I used the v1.0.0-alpha2 version)

2014_10_12_000000_create_users_table`` PHP Fatal error: Declaration of LaravelFreelancerNL\Aranguent\Schema\Builder::__call(string $method, mixed $args): void must be compatible with Illuminate\Database\Schema\Builder::__call($method, $parameters) in /home/bridgebrain/web/infinatummedia.com/public_html/vendor/laravel-freelancer-nl/aranguent/src/Schema/Builder.php on line 218

Symfony\Component\ErrorHandler\Error\FatalError

Declaration of LaravelFreelancerNL\Aranguent\Schema\Builder::__call(string $method, mixed $args): void must be compatible with Illuminate\Database\Schema\Builder::__call($method, $parameters)

at vendor/laravel-freelancer-nl/aranguent/src/Schema/Builder.php:218
214▕
215▕ /**
216▕ * Silently catch the use of unsupported builder methods.
217▕ */
➜ 218▕ public function __call(string $method, mixed $args): void
219▕ {
220▕ Log::warning("The Aranguent Schema Builder doesn't support method '$method'\n");
221▕ }
222▕ }

Whoops\Exception\ErrorException

Declaration of LaravelFreelancerNL\Aranguent\Schema\Builder::__call(string $method, mixed $args): void must be compatible with Illuminate\Database\Schema\Builder::__call($method, $parameters)

at vendor/laravel-freelancer-nl/aranguent/src/Schema/Builder.php:218
214▕
215▕ /**
216▕ * Silently catch the use of unsupported builder methods.
217▕ */
➜ 218▕ public function __call(string $method, mixed $args): void
219▕ {
220▕ Log::warning("The Aranguent Schema Builder doesn't support method '$method'\n");
221▕ }
222▕ }

  +1 vendor frames

2 [internal]:0
Whoops\Run::handleShutdown()

Add graph statements?

See if and how we can add an easy to use graph clause to the query builder.
Including collection/graph selection, directions, depth, pruning etc.

What would be a good api?
I'm thinking of adding in a similar way as joins are created in the query builder.
That should let us isolate most graph specific methods.

Research conversion of _key to and from id.

For package compatibility it is probably required to supply an id. ArangoDB uses both _id and _key. Where the latter has a SQL like structure as _id includes the collection.

Common problems and considerations:

  • Even though some packages allow you to override the models in use the relationships between them usually don't grab the model's keyname but assume 'id' regardless. This leads to more overriding/overloading than otherwise necessary.
    It's an illusion to think that new and existing packages will all start to grab the key name from the model.
  • A model's routeKey falls back to id. _id breaks routes due to the slash in its {collection}/{_key} structure. While the routeKey can be set separately this then leads to problems in other packages that assume the routekey is the id.
  • _id must remain available for graph queries
  • _key usage is slightly more performant than _id. So preferred by default.
  • an id attribute might be nested deeper within a document in which case it should not be convert to _key

Test third-party package compatibility / ease of use

Test against popular packages

  • barryvdh/laravel-debugbar
  • Laravel Horizon
  • Spatie Permissions
  • Plank Laravel Mediable
  • Laravel Jetstream
  • Laravel Passport
  • Laravel Sanctum
  • Spatie Medialibrary
  • spatie/laravel-multitenancy
  • Cashier Mollie

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.