PHP code example of grobmeier / cicada

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

    

grobmeier / cicada example snippets




use Cicada\Application;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

$app = new Application();

// Add a route
$app->get('/hello/{name}', function (Application $app, Request $request, $name) {
    return new Response("Hello $name");
});

$app->run();

$app->exception(function (NotImplementedException $ex) {
    $msg = "Dreadfully sorry, old chap, but tis' not implemented yet.";
    return new Response($msg, Response::HTTP_INTERNAL_SERVER_ERROR);
});

$app->exception(function (SomeException $ex) {
    return new Response("Arrrghhhhh", Response::HTTP_INTERNAL_SERVER_ERROR);
});


$app->exception(function (OtherException $ex) {
    return new Response("FFFFUUUUUUU...", Response::HTTP_INTERNAL_SERVER_ERROR);
});

// If all else fails, this will catch any exceptions
$app->exception(function (Exception $ex) {
    $msg ="Something went wrong. The incident has been logged and our code monkeys are on it.";
    return new Response($msg, Response::HTTP_INTERNAL_SERVER_ERROR);
});