PHP code example of grnspc / essentials

1. Go to this page and download the library: Download grnspc/essentials 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/ */

    

grnspc / essentials example snippets




declare(strict_types=1);

namespace App\Actions;

use Illuminate\Database\DatabaseManager;
use Throwable;

final readonly class CreateUserAction
{
     public function __construct(private DatabaseManager $database) {}

    /**
     * Execute the action.
     *
     * @throws Throwable
     */
    public function handle(): void
    {
        $this->database->transaction(
            callback: function (): void => {
                //
            },
            attempts: 3
        );
    }
}

Grnspc\Essentials\Configurables\AutomaticallySuffixActionClass::class => false,

// config/essentials.php
return [
    Grnspc\Essentials\Configurables\ShouldBeStrict::class => true,
    Grnspc\Essentials\Configurables\Unguard::class => false,
    // other configurables...
];
bash
php artisan vendor:publish --tag=essentials-config
bash
php artisan make:action CreateUserAction
bash
php artisan essentials:pint {--force} {--backup}
bash
php artisan essentials:rector {--force} {--backup}
bash
php artisan vendor:publish --tag=essentials-stubs