PHP code example of longman / laravel-lodash

1. Go to this page and download the library: Download longman/laravel-lodash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

longman / laravel-lodash example snippets


'providers' => [
    . . .
    /*
     * Package Service Providers...
     */
    Longman\LaravelLodash\ServiceProvider::class,
    . . .
],

    . . .
    'debug' => [
        'ips' => [ // IP list for enabling debug mode
            //'127.0.0.1',
        ],
    ],
    . . .

    $table->unsignedInteger('created_by')->nullable();
    $table->unsignedInteger('updated_by')->nullable();
    $table->unsignedInteger('deleted_by')->nullable();

    $table->uuid('id')->primary();

    $items = (new User)->with([
        'photos' => function (BelongsToMany $builder) {
            // Select via union. There you should pass pivot table fields array
            $builder->limitPerGroupViaUnion(3, ['user_id', 'photo_id']);
            // or
            // Select via subquery
            $builder->limitPerGroupViaSubQuery(3);
        }, 'other.relation1', 'other.relation2'
    ]);
    $items = $items->get();

    . . .
    Longman\LaravelLodash\Cache\CacheServiceProvider::class,
    Longman\LaravelLodash\Redis\RedisServiceProvider::class,
    . . .

    . . .
    'redis' => [
        'client' => 'phpredis',
        
        'clusters' => [
            'options' => [
                'lazy_connect'      => true,
                'connect_timeout'   => 1,
                'read_timeout'      => 3,
                'password'          => env('REDIS_PASSWORD', null),
                'database'          => env('REDIS_DATABASE', 0),
                'prefix'            => env('REDIS_PREFIX'),
                'serializer'        => Redis::SERIALIZER_IGBINARY,
                'compression'       => Redis::COMPRESSION_ZSTD,
                'compression_level' => Redis::COMPRESSION_ZSTD_DEFAULT,
            ],

            'default' => [
                [
                    'host' => env('REDIS_SHARD1_HOST', '127.0.0.1'),
                    'port' => env('REDIS_SHARD1_PORT', 6379),
                ],
                [
                    'host' => env('REDIS_SHARD2_HOST', '127.0.0.2'),
                    'port' => env('REDIS_SHARD2_PORT', 6379),
                ],
                . . .
            ],
        ],
    ],
    . . .

    . . .
    Longman\LaravelLodash\Queue\QueueServiceProvider::class,
    . . .

    . . .
    'sqs_fifo' => [
        'driver'  => 'sqs.fifo',
        'version' => 'latest',
        'key'     => env('AWS_ACCESS_KEY_ID'),
        'secret'  => env('AWS_SECRET_ACCESS_KEY'),
        'prefix'  => env('AWS_SQS_URL'),
        'queue'   => env('AWS_SQS_DEFAULT_QUEUE'),
        'region'  => env('AWS_DEFAULT_REGION'),
        'options' => [
            'type'      => 'fifo', // fifo, normal
            'polling'   => 'long', // long, short
            'wait_time' => 20,
        ],
    ],
    . . .

    . . .
    Longman\LaravelLodash\Elasticsearch\ElasticsearchServiceProvider::class,
    . . .

    . . .
    'elasticsearch' => [
        'enabled'          => env('ELASTICSEARCH_ENABLED', false),
        'log_channel'      => ['daily'],
        'hosts'            => [
            [
                'host' => env('ELASTICSEARCH_HOST', 'localhost'),
                'port' => env('ELASTICSEARCH_PORT', 9200),
            ],
        ],
        'connectionParams' => [
            'client' => [
                'timeout'         => env('ELASTICSEARCH_TIMEOUT', 3),
                'connect_timeout' => env('ELASTICSEARCH_TIMEOUT', 3),
            ],
        ],
    ],
    . . .

    $elasticsearch_manager = app(ElasticsearchManagerContract::class);
    
    // Call wrapped methods
    $elasticsearch_manager->createIndex('some-index');
    
    // Or get native client and access their methods
    $client = $elasticsearch_manager->getClient();
    $client->indices()->create($params);



    $elasticsearch_manager = app(ElasticsearchManagerContract::class);
    $results = $elasticsearch_manager->performSearch($query); 


    . . .
    if (config('app.debug')) {
        $checker = new ComposerChecker(base_path());
        $checker->checkHash();
    }
    . . .

    . . .
    'simple' => [
        'enabled'  => env('SIMPLE_AUTH_ENABLED', true),
        'user'     => env('SIMPLE_AUTH_USER', 'user'),
        'password' => env('SIMPLE_AUTH_PASS', 'secret'),
    ],
    . . .

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\AvailableDiskSpace::class => [
    'paths' => [
        '/' => '100G', // At least 100G should be available for the path "/"
        '/var/www' => '5G',
    ],
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\FilesystemsAreAvailable::class => [
    'disks' => [
        'local',
        's3',
    ],
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\ElasticsearchCanBeAccessed::class => [
    'client' => ElasticSearchClient::class,
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\PhpIniOptions::class => [
    'options' => [
        'upload_max_filesize' => '>=128M',
        'post_max_size'       => '>=128M',
        'memory_limit'        => '>=128M',
        'max_input_vars'      => '>=10000',
        'file_uploads'        => '1',
        'disable_functions'   => '',
    ],
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\RedisCanBeAccessed::class => [
    'default_connection' => true,
    'connections'        => ['sessions'],
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\ServersArePingable::class => [
    'servers' => [
        [
            'host'    => config('app.url'),
            'port'    => 80,
            'timeout' => 1,
        ],
        [
            'host'    => 'sqs.eu-west-1.amazonaws.com',
            'port'    => 443,
            'timeout' => 3,
        ],
        [
            'host'    => 'www.googleapis.com',
            'port'    => 443,
            'timeout' => 3,
        ],
    ],
],
...

...
\Longman\LaravelLodash\SelfDiagnosis\Checks\HorizonIsRunning::class,
...