Frankie - A frankenstein micro-framework for PHP

Overview

Frankie - A frankenstein micro-framework for PHP

Build Status

Features

Frankie is a micro-framework focused on annotation. The goal is to use annotation in order to do almost everything in the framework.

  • Annotated Routes (Routing)
  • Annotated Injections (Dependencies)
  • Annotated Request Flow (Application Flow)

Mainly Frankie is a framework for create RESTful applications and microservices.

Discover more on the documentation

Hands-on!

The goal is focus on actions and attach before and action events using annotations

eventManager->trigger("mark-it", $element); // ... } } ">

/**
 * @Before(targetClass="HttpAuth", targetMethod="basic")
 * @After(targetClass="Serializer", targetMethod="toJson")
 */
class MyController
{
    /**
     * @Inject
     * @var Zend\EventManager\EventManager
     */
    private $eventManager;

    /**
     * @Route("/my/path/{id}", methods={"GET"})
     * @Before(targetClass="MyHook\ThisOne", targetMethod="count")
     * @Before(targetClass="Stopwatch", targetMethod="start")
     * @After(targetClass="Stopwatch", targetMethod="stop")
     */
    public function get(Request $request, Response $response, $id)
    {
        // ...
        $this->eventManager->trigger("mark-it", $element);
        // ...
    }
}

Testing with SpecBDD - PHPSpec

shouldBeCalledTimes(1); $this->get($request, $response); } }">


namespace spec;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Zend\EventManager\EventManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class MyControllerSpec extends ObjectBehavior
{
    function let(EventManager $em)
    {
        $this->setEventManager($em);
    }

    function it_is_initializable()
    {
        $this->shouldHaveType('MyController');
    }

    function it_should_trigger_the_mark_event(
        Request $request, Response $response, EventManager $em
    )
    {
        $em->trigger("mark-it", Argument::Any())->shouldBeCalledTimes(1);

        $this->get($request, $response);
    }
}
Comments
  • Annotations from superclass

    Annotations from superclass

    Actually the framework never reads annotations from a superclass

    <?php
    /**
     * @Before(targetClass="HttpAuth", targetMethod="basic")
     */
    class AuthController { ... }
    
    <?php
    class MyController extends AuthController { ... }
    
    enhancement help wanted question 
    opened by wdalmut 2
  • Return response should short-circuit the execution

    Return response should short-circuit the execution

    If a Reponse is returned by any action the flow should be immediately stopped!

    <?php
    class HttpAuth
    {
        public function basic($request, $response)
        {
            // Any check...
    
            $response->setStatusCode(401);
            return $response;
        }
    }
    
    enhancement question 
    opened by wdalmut 1
  • events are in reverse order

    events are in reverse order

    Actually we execute method steps first... We should separate steps:

    before annotation -> class to methods after annotation -> method to class

    <?php
    /**
     * @Before(targetClass="B", targetMethod="b")
     * @After(targetClass="C", targetMethod="c")
     */
    class A
    {
        /**
         * @Before(targetClass="D", targetMethod="d")
         * @After(targetClass="E", targetMethod="e")
         */
        public function a(){}
    }
    

    Should result in

    • B::b
    • D::d
    • A::a
    • E::e
    • C::c
    bug 
    opened by wdalmut 1
  • Tests variadic methods

    Tests variadic methods

    This commits solve the variadic problem:

    • https://github.com/symfony/symfony/pull/13690#issuecomment-127016281
    • https://github.com/symfony/symfony/issues/15425
    opened by wdalmut 0
  • Event re-execute class steps!

    Event re-execute class steps!

    See that effectively the execution for the before step is:

    Corley\\Demo\\Controller\\Tests\\Two::methodB
    Corley\\Demo\\Controller\\Tests\\One::methodC
    Corley\\Demo\\Controller\\Tests\\Two::methodB
    Corley\\Demo\\Controller\\Tests\\One::action
    

    Be want:

    Corley\\Demo\\Controller\\Tests\\Two::methodB
    Corley\\Demo\\Controller\\Tests\\One::methodC
    Corley\\Demo\\Controller\\Tests\\One::action
    

    Just because One::methodC have also the Two::methodB before step as the One::action (same base class)

    Also a circular recursion actually is not avoidable

    Related to #7

    enhancement 
    opened by wdalmut 0
Releases(0.0.6)
  • 0.0.6(Jul 16, 2017)

A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
Lemon is php micro framework built for simple applications.

Lemon is simple micro framework that provides routing, etc.

Lemon 20 Dec 16, 2022
TidyPHP is a micro php framework to build web applications

TidyPHP is a micro MVC PHP Framework made to understand how PHP Frameworks work behind the scense and build fast and tidy php web applications.

Amin 15 Jul 28, 2022
ExEngine is an ultra lightweight micro-services framework for PHP 5.6+

ExEngine is an ultra lightweight micro-services framework for PHP 5.6+. Documentation Checkout the Wiki. Examples Click here to browse examples, also

linkfast.io 1 Nov 23, 2020
REST-like PHP micro-framework.

Phprest Description REST-like PHP micro-framework. It's based on the Proton (StackPhp compatible) micro-framework. Phprest gives you only the very bas

Phprest 312 Dec 30, 2022
Silly CLI micro-framework based on Symfony Console

currentMenu home Silly CLI micro-framework based on Symfony Console. Professional support for Silly is available via Tidelift Video introduction in fr

Matthieu Napoli 862 Dec 23, 2022
Blink is a micro web framework for building long-running and high performance services

Blink is a micro web framework for building long-running and high performance services, the design heavily inspired by Yii2 and Laravel. Blink aims to provide the most expressive and elegant API and try to make the experience of web development as pleasant as possible.

Jin Hu 837 Dec 18, 2022
StackSync is a simple, lightweight and native fullstack PHP mini-framework.

StackSync is a fullstack PHP mini framework, with an MVC structure, custom API system with a Middleware and JWT authentication, components based views, flexible routing, PSR4 autoloading. Essential files generation (migrations, seeders, controllers and models) and other operations can be executed through custom commands.

Khomsi Adam 3 Jul 24, 2022
PHP微服务框架即Micro Service Framework For PHP

Micro Service Framework For PHP PHP微服务框架即“Micro Service Framework For PHP”,是Camera360社区服务器端团队基于Swoole自主研发现代化的PHP协程服务框架,简称msf或者php-msf,是Swoole的工程级企业应用框

Camera360 1.8k Jan 5, 2023
The Laravel Lumen Framework.

Lumen PHP Framework Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe d

The Laravel Framework 7.6k Jan 7, 2023
Slim Framework 4 Skeleton Application

Slim Framework 4 Skeleton Application Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application. This app

Slim Framework 1.5k Dec 29, 2022
🐺 Lightweight and easy to use framework for building web apps.

Wolff Web development made just right. Wolff is a ridiculously small and lightweight PHP framework, intended for those who want to build web applicati

Alejandro 216 Dec 8, 2022
Larasymf - mini framework for medium sized projects based on laravel and symfony packages

Larasymf, PHP Framework Larasymf, as its says is a mini framework for medium sized projects based on laravel and symfony packages We have not yet writ

Claude Fassinou 6 Jul 3, 2022
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.

Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP. ?? Files and functions as first-class citi

Leo Cavalcante 1.1k Dec 30, 2022
VELOX - The fastest way to build simple websites using PHP!

VELOX The fastest way to build simple websites using PHP! Table of Contents Installation About VELOX Architecture Config Classes Functions Themes Chan

Marwan Al-Soltany 53 Sep 13, 2022
A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery.

PHP Netflix Eureka Client A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery. Installation You can install this package

Hamid Mohayeji 72 Aug 21, 2022
Yet another PHP Microframework.

ρ Yet another PHP Microframework. The premise of this framework is to be backwards-compatible (PHP <= 5.6) with powerful utilities (Like caching and l

null 0 Apr 6, 2022
A Frankenstein's monster: Kirby inside of Laravel.

A Kirby-Laravel Starter Kit This is an experimental starter kit for using Kirby within Laravel (a little like Statamic). In my limited experience it r

Brandon Turner 4 Mar 19, 2022
A PHP project/micro-package generator for PDS compliant projects or micro-packages.

Construct A PHP project/micro-package generator for PDS compliant projects or micro-packages. Installation Construct should be installed globally thro

Jonathan Torres 263 Sep 28, 2022
Framework X is a simple and fast micro framework based on PHP

Framework X is a simple and fast micro framework based on PHP. I've created a simple CRUD application to understand how it works. I used twig and I created a custom middleware to handle PUT, DELETE methods.

Mahmut Bayri 6 Oct 14, 2022