alfreinsco/tesaja
Minimal Laravel starter package that demonstrates how to ship and publish Blade views. Install via Composer, optionally publish views with the hello-views tag, then render hello-starter::hello (or the published vendor view). MIT licensed.
Installation Add the package via Composer:
composer require alfreinsco/tesaja
Publish the config file (if available):
php artisan vendor:publish --provider="Alfreinsco\Tesaja\TesajaServiceProvider"
Service Provider & Facade
Ensure the service provider is registered in config/app.php under providers:
Alfreinsco\Tesaja\TesajaServiceProvider::class,
Use the facade for quick access:
use Alfreinsco\Tesaja\Facades\Tesaja;
First Use Case: Basic Integration Initialize Tesaja in a controller or service:
public function index()
{
$response = Tesaja::process('input_data');
return response()->json($response);
}
Check the README for default configuration and required parameters.
Request Processing Use Tesaja to handle incoming requests (e.g., API payloads, form submissions):
public function store(Request $request)
{
$validated = $request->validate([...]);
$result = Tesaja::process($validated);
return response()->json($result);
}
Middleware Integration Process data before it reaches controllers:
namespace App\Http\Middleware;
use Closure;
use Alfreinsco\Tesaja\Facades\Tesaja;
class ProcessTesajaData
{
public function handle($request, Closure $next)
{
$request->merge(['processed_data' => Tesaja::process($request->all())]);
return $next($request);
}
}
Register in app/Http/Kernel.php:
protected $middleware = [
\App\Http\Middleware\ProcessTesajaData::class,
];
Event Listeners
Trigger Tesaja on model events (e.g., created, updated):
namespace App\Listeners;
use Alfreinsco\Tesaja\Facades\Tesaja;
class ProcessModelData
{
public function handle($event)
{
Tesaja::process($event->model->toArray());
}
}
Command-Line Usage Run Tesaja via Artisan commands for batch processing:
php artisan tesaja:process --input="path/to/data.json"
Extend the command for custom logic:
namespace App\Console\Commands;
use Alfreinsco\Tesaja\Facades\Tesaja;
use Illuminate\Console\Command;
class CustomTesajaCommand extends Command
{
protected $signature = 'tesaja:custom {input}';
public function handle()
{
$data = file_get_contents($this->argument('input'));
$result = Tesaja::process(json_decode($data, true));
$this->info($result);
}
}
Tesaja facade into services for reusable logic.public function toArray($request)
{
return [
'data' => Tesaja::process($this->resource),
];
}
Tesaja::shouldReceive('process')->once()->andReturn(['mocked' => true]);
Configuration Overrides
Ensure config/tesaja.php is published and configured correctly. Defaults may not match your needs:
'timeout' => 30, // Default may be too low for heavy processing
'retries' => 3, // Ensure retries are enabled for transient failures
Input Validation Tesaja may silently fail on malformed input. Validate data before processing:
$validated = $request->validate([
'required_field' => 'required|string',
]);
$result = Tesaja::process($validated);
Rate Limiting If Tesaja interacts with external APIs, implement rate-limiting middleware:
Route::middleware(['throttle:100,1'])->group(function () {
// Tesaja-heavy routes
});
Logging Enable debug logging for troubleshooting:
'debug' => env('APP_DEBUG', false),
Check logs in storage/logs/laravel.log for errors.
verbose config option to log detailed steps:
'verbose' => true,
dd() or dump() to inspect intermediate states:
$intermediate = Tesaja::process($data, ['debug' => true]);
dd($intermediate);
try {
$result = Tesaja::process($data);
} catch (\Exception $e) {
\Log::error("Tesaja error: " . $e->getMessage());
return response()->json(['error' => 'Processing failed'], 500);
}
Custom Processors Extend Tesaja’s core logic by creating a custom processor:
namespace App\Services;
use Alfreinsco\Tesaja\Contracts\Processor;
class CustomProcessor implements Processor
{
public function process($data)
{
// Custom logic
return $data;
}
}
Bind it in a service provider:
$this->app->bind(
\Alfreinsco\Tesaja\Contracts\Processor::class,
App\Services\CustomProcessor::class
);
Hooks & Events Listen for Tesaja events (if supported) to inject logic:
event(new \Alfreinsco\Tesaja\Events\ProcessingStarted($data));
Testing Helpers Create a test helper to mock Tesaja:
if (app()->environment('testing')) {
Tesaja::shouldReceive('process')->andReturn(['test' => true]);
}
$cached = Cache::remember('tesaja_' . md5($input), 3600, function () use ($input) {
return Tesaja::process($input);
});
TesajaJob::dispatch($data)->onQueue('tesaja');
namespace App\Jobs;
use Alfreinsco\Tesaja\Facades\Tesaja;
use Illuminate\Bus\Queueable;
class TesajaJob
{
use Queueable;
public function handle()
{
Tesaja::process($this->data);
}
}
How can I help you explore Laravel packages today?