PHP code example of bjornbasar / karhu-skeleton

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

    

bjornbasar / karhu-skeleton example snippets


$app = new Karhu\App();
$app->router()->scanControllers(

   namespace App\Controllers;

   use Karhu\Attributes\Route;
   use Karhu\Http\Request;
   use Karhu\Http\Response;

   final class GreetController {
       #[Route('/greet/{name}', methods: ['GET'])]
       public function greet(Request $request): Response {
           return (new Response())->json(['hello' => $request->routeParams()['name']]);
       }
   }
   

   return [
       App\Controllers\HomeController::class,
       App\Controllers\GreetController::class,
   ];
   

karhu-skeleton/
├── app/
│   ├── Commands/HelloCommand.php       # #[Command] CLI sample
│   └── Controllers/HomeController.php  # #[Route] HTTP sample
├── config/
│   ├── commands.php                    # CLI command registry
│   └── controllers.php                 # Controller registry (route scan input)
├── public/index.php                    # Front controller
├── docs/deployment/                    # Reference deployment notes
└── composer.json