PHP code example of gts-meghni / laravel-essentials-kit

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

    

gts-meghni / laravel-essentials-kit example snippets


->withMiddleware(function (Middleware $middleware): void {
    $middleware->append(ForceJsonResponse::class);
    $middleware->append(RequestId::class);
})
->withExceptions(function (Exceptions $exceptions): void {
    $exceptions->shouldRenderJsonWhen(static fn (): bool => true);
    $exceptions->render(new ApiExceptionRenderer);
})

// routes/api.php
Route::prefix('client')
    ->name('client.')
    ->group(base_path('routes/api/client.php'));

Route::prefix('backoffice')
    ->name('backoffice.')
    ->group(base_path('routes/api/backoffice.php'));

$code = app(OtpStore::class)->issue($user->phone);   // send this yourself

app(OtpStore::class)->verify($user->phone, $request->string('code')->toString());

php artisan migrate
php artisan db:seed --class=AlgeriaGeoSeeder

Province::where('code', '16')->first()->translatedName();  // "الجزائر" under the ar locale
$commune->translatedName('fr');
$province->communes;

if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
    $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
    $this->app->register(TelescopeServiceProvider::class);
}

new OA\Response(
    response: 422,
    description: 'The request was invalid.',
    content: new OA\JsonContent(ref: '#/components/schemas/ValidationErrorResponse'),
),

'timezone' => env('APP_TIMEZONE', 'Africa/Algiers'),
bash
php artisan essentials:install

app/Support/Otp/OtpGenerator.php
app/Support/Otp/RandomOtpGenerator.php
app/Support/Otp/FakeOtpGenerator.php
app/Support/Otp/OtpStore.php
config/otp.php

database/data/algeria.json
database/migrations/0001_01_01_000010_create_provinces_table.php
database/migrations/0001_01_01_000011_create_communes_table.php
database/seeders/AlgeriaGeoSeeder.php
app/Models/Province.php
app/Models/Commune.php

config/l5-swagger.php
app/Http/Middleware/ProtectApiDocs.php
app/OpenApi/Client/OpenApiDefinition.php
app/OpenApi/Client/OpenApiConfig.php
app/OpenApi/Client/Endpoints/HealthEndpoint.php
app/OpenApi/Backoffice/OpenApiDefinition.php
app/OpenApi/Backoffice/OpenApiConfig.php
app/OpenApi/Backoffice/Endpoints/HealthEndpoint.php
app/OpenApi/Schemas/ErrorResponseSchema.php
app/OpenApi/Schemas/ValidationErrorResponseSchema.php
app/OpenApi/Schemas/PaginationSchema.php
app/OpenApi/Schemas/PaginationMetaSchema.php
app/OpenApi/Parameters/AcceptLanguageHeaderParameter.php