PHP code example of horizom / app

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

    

horizom / app example snippets


$name = config('app.name');         // "Horizom"
$dsn  = config('database.default'); // "development"

$router->get('/', 'MainController@index');

$router->group(['prefix' => 'api'], function (RouteCollector $router) {
    $router->get('/status',  'ApiController@status');
    $router->get('/version', 'ApiController@version');
});



declare(strict_types=1);

namespace App\Controllers;

use Psr\Http\Message\ResponseInterface;

final class ApiController
{
    public function status(): ResponseInterface
    {
        return response()->json(['status' => 'UP']);
    }
}

$app->add(new \App\Middlewares\CorsMiddleware());

// app/Middlewares/CorsMiddleware.php
private array $allowedOrigins = [
    'https://myapp.com',
    'https://www.myapp.com',
];

├── app/
│   ├── Controllers/       # Request handlers (PSR-7)
│   ├── Middlewares/       # PSR-15 middleware (CORS, errors…)
│   ├── Models/            # Domain models
│   └── Providers/         # Service providers
├── bootstrap/
│   ├── app.php            # Application bootstrap
│   └── dependencies.php   # Middleware registration
├── config/
│   ├── app.php            # App settings
│   ├── auth.php           # JWT / auth settings
│   └── database.php       # Database connections
├── public/
│   └── index.php          # Front controller
├── resources/
│   └── views/             # Blade templates
├── routes/
│   ├── web.php            # Web routes
│   └── api.php            # API routes
└── tests/
    └── Unit/              # PHPUnit test suites

tests/
└── Unit/
    ├── Controllers/
    │   └── ApiControllerTest.php
    └── Middlewares/
        ├── CorsMiddlewareTest.php
        └── ErrorHandlerMiddlewareTest.php