Enjoy these free Code Nuggets?

Your support helps us create more high-quality content and unlocks exclusive premium nuggets via a personal activation link.

Support Our Work & Get Exclusive Access
🤖 New — AI Training

Learn to code with AI, not just about it.

Beyond free snippets, we run hands-on training in AI-assisted coding — teaching developers, teams and beginners how to build real software faster using modern AI tools. You bring the ideas; we show you how to ship them with an AI pair-programmer at your side.

  • ✔ Prompting & pairing with AI coding assistants to write, debug and refactor real code
  • ✔ Turning plain-English ideas into working apps, scripts and automations
  • ✔ Reviewing AI output safely — spotting bugs, security gaps and hallucinations
  • ✔ Live cohorts, team workshops and 1-on-1 mentoring — remote or on-site in Kenya
ai-pair-session.md

# You describe it…

"Build me a booking form that emails the client."

# …the AI drafts it…

▸ generating form + mailer…

â–¸ 24 lines written, 0 errors

# …and we teach you to lead it.

✱ You stay the engineer. AI is the tool.

PHP nuggets

3 nuggets found

Clear filter

KenyaVerified Gateway: National ID & Business Registry Verification API (Premium)

PHP php

Unified identity verification & anti-fraud gateway for verifying Kenya National ID numbers, business registration status, and tax compliance via secure REST webhooks.

// KenyaVerified National Registry Verification API
namespace App\Services;

use Illuminate\Support\Facades\Http;

class KenyaVerifiedService {
    public static function verifyNationalId(string $idNumber, string $dob): array {
        $response = Http::withHeaders([
            'X-API-KEY' => confi...

Immutable Value Objects with PHP 8.2+ Readonly Properties & Classes

PHP php

Enforcing True Domain Safety with Native Readonly Classes in PHP 8.2+ PHP 8.2 introduced native readonly class declarations, ensuring that every property cannot be modified after constructor initialization. Domain Validation:...

<?php

declare(strict_types=1);

namespace App\Domain\ValueObjects;

use InvalidArgumentException;

readonly class Money
{
    public function __construct(
        public int $amountInCents,
        public string $currency = 'KES'
    ) {
        if ($this->amountInCents < 0) {
            throw new...

Transforming Arrays with map, filter and reduce (Premium)

PHP php

Loops that build up a result variable are easy to get wrong. PHP's array functions let you describe what you want — transform, keep, or fold — in a single...

$orders = [
    ['item' => 'Pen',    'qty' => 3, 'price' => 50],
    ['item' => 'Book',   'qty' => 1, 'price' => 400],
    ['item' => 'Marker', 'qty' => 5, 'price' => 80],
];

// Only orders worth 200+, as "item: total"
$lines = array_map(
    fn ($o) => "{$o['item']}: " . ($o['qty'] * $o['price']),...