2017 © Pedro Peláez
 

library cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

image

cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  • Tuesday, May 9, 2017
  • by ihabunek
  • Repository
  • 2 Watchers
  • 8 Stars
  • 5,239 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 20 Versions
  • 3 % Grown

The README.md

Cicada

A micro framework for creating traditional or REST-like web applications., (*1)

Latest Stable Version Total Downloads Build Status Coverage Status License, (*2)

Installation

Add Cicada as a requirement for your project via Composer:, (*3)

composer require "cicada/cicada=@stable"

Usage

Minimal application:, (*4)

require '../vendor/autoload.php';

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();

This application has one route which will match GET requests starting with /hello/ and will forward the matched {name} into the callback function as $name., (*5)

The callback function should return a Response object. If it returns a string, it will implicitly be converted into a Response., (*6)

Handling exceptions

It is possible that route callbacks throw an exception. By default, Cicada will in this case return a HTTP 500 response (Internal Server Error). However, it is possible to add exception handlers which will intercept specific exceptions and return an appropriate response., (*7)

For example, if you want to catch a custom NotImplementedException and return a custom error message:, (*8)

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

The callback function passed to $app->exception() must have a single argument and that argument must have a class type hint which denotes the exception class which it will handle., (*9)

It's possible to specify multiple exception handlers and they will be tried in order in which they were specified:, (*10)

$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);
});

The Versions

09/05 2017

dev-master

9999999-dev https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

09/05 2017
26/04 2017

dev-develop

dev-develop https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

03/02 2016
12/03 2015
25/11 2014

0.4.11

0.4.11.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

21/10 2014

0.4.10

0.4.10.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

15/10 2014

0.4.9

0.4.9.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

25/08 2014

0.4.8

0.4.8.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

25/08 2014

0.4.7

0.4.7.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

04/06 2014

0.4.6

0.4.6.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

03/06 2014

0.4.5

0.4.5.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

01/06 2014

0.4.4

0.4.4.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

27/05 2014

0.4.3

0.4.3.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

19/05 2014

0.4.2

0.4.2.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

18/05 2014

0.4.1

0.4.1.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

17/05 2014

0.4.0

0.4.0.0 https://github.com/cicada/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework

15/05 2014

0.3.0

0.3.0.0 https://github.com/grobmeier/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

framework

15/01 2014

0.2.0

0.2.0.0 https://github.com/grobmeier/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

framework

09/12 2013

0.1.0

0.1.0.0 https://github.com/grobmeier/cicada

Tiny PHP framework for quickly creating webapps, inspired by Rubys Sinatra

  Sources   Download

Apache-2.0

The Requires

 

framework