PHP code example of marcuwynu23 / narciso

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

    

marcuwynu23 / narciso example snippets



Marcuwynu23\Narciso\Application;

$app = new Application();

$app->route('GET', '/', function ($app) {
    $app->json(['message' => 'Hello World']);
});

$app->route('GET', '/users/:id', function ($app, $params) {
    $app->json(['user_id' => $params['id']]);
});

$app->run();

$app = new Application();
$app->setViewPath(__DIR__ . '/views');
$app->setPoweredBy(false);
$app->handleSession();
$app->useSecurityHeaders();
$app->useCors(['https://myapp.com']);
$app->useRateLimit(60, 60);
$app->handleDatabase([
    'type'     => 'sqlite',
    'database' => __DIR__ . '/data/app.db',
]);
bash
php -r "
bash
php -S localhost:8080 index.php

narciso/
├── src/Application.php          # Main class (~500 lines)
├── src/Middleware/
│   ├── MiddlewareInterface.php  # Middleware contract
│   ├── CorsMiddleware.php      # CORS handler
│   ├── RateLimitMiddleware.php # Per-IP rate limiter
│   └── SecurityHeadersMiddleware.php # Security headers
├── test/                       # PHPUnit test suite
│   ├── TestCase.php
│   ├── ApplicationTest.php     # 26 tests
│   └── MiddlewareTest.php      # 10 tests
├── samples/                    # Example applications
│   ├── 01_basic_routing.php
│   └── ...
└── docs/                       # Documentation website