Code Monkey home page Code Monkey logo

antidot-docs's Introduction

Antidot Framework

Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status Maintainability

This package contains core components to make Antidot Framework work.

  • PSR-15 Middleware
  • Router
  • Server
  • Error Handlers

Requirements

v2.x.x

  • PHP >= 8.1

v1.x.x

  • PHP >= 7.4.0

Installation

composer require antidot-fw/framework

Usage

Take a look at Getting Started Guide in our Docs Site.

antidot-docs's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

peter279k

antidot-docs's Issues

Routed Pipelines should be problematic

Describe the bug
I think the Routed Pipelines steps are not completed.

To Reproduce
Steps to reproduce the behavior:

  1. Using composer create-project antidot-fw/antidot-framework-starter project-name command.
  2. Creating the ./src/Application/Http/Handler/ApiPage.php request handler class.

The ApiPage contents are as follows:

<?php

declare(strict_types=1);

namespace App\Application\Http\Handler;

use App\Application\Event\SomeEvent;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Laminas\Diactoros\Response\JsonResponse;

class ApiPage implements RequestHandlerInterface
{
    /** @var EventDispatcherInterface */
    private $eventDispatcher;

    public function __construct(EventDispatcherInterface $eventDispatcher)
    {
        $this->eventDispatcher = $eventDispatcher;
    }

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $this->eventDispatcher->dispatch(SomeEvent::occur());

        return new JsonResponse([
            'docs' => 'https://antidotfw.io',
            'Message' => 'Welcome to Antidot Framework Starter'
        ]);
    }
}
  1. Adding the App\Application\Http\Handler\ApiPage: on ./config/services/dependencies.prod.yaml file. And file contents are:
services:
  App\Application\Http\Handler\HomePage:
  App\Application\Http\Handler\ApiPage:
  App\Application\Http\Handler\SomeMiddleware:
  App\Application\EventListener\SomeEventListener:
    tags:
      - { name: 'event_listener', event: 'App\Application\Event\SomeEvent' }

  some.command:
    class: App\Application\Command\SomeCommandExample
    tags:
      - { name: 'console.command', command: 'my:custom:command' }

parameters:
  debug: true
  config_cache_enabled: false
  monolog:
    handlers:
      default:
        type: 'stream'
        options:
          stream: 'var/log/%date%-default.log'
          level: 400

  1. And routes.php contents are:
<?php

declare(strict_types=1);

use Antidot\Application\Http\Application;
use App\Application\Http\Handler\HomePage;
use App\Application\Http\Handler\ApiPage;
use App\Application\Http\Handler\SomeMiddleware;
use Psr\Container\ContainerInterface;

/**
 * Setup routes with a single request method:
 *
 * $app->get('/', App\Handler\HomePageHandler::class, 'home');
 * $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
 * $app->put('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.put');
 * $app->patch('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.patch');
 * $app->delete('/album/:id', App\Handler\AlbumDeleteHandler::class, 'album.delete');
 *
 * Or with multiple request methods:
 *
 * $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
 */
return static function (Application $app, ContainerInterface $container) : void {
    $app->get('/', [SomeMiddleware::class, HomePage::class], 'home');
    $app->get('/api', [SomeMiddleware::class, ApiPage::class], 'api');
};
  1. See error

Expected behavior
It will be worked for requesting the /api route with GET method.

Screenshots
The error log is as follows and it's available on ./var/log/ folder:
[2021-01-19T02:29:03.544855+08:00] default.ERROR: {"message":"Invalid handler name name given App\\Application\\Http\\Handler\\ApiPage.","code":0,"file":"\/data\/cloud-printer-api\/vendor\/antidot-fw\/framework\/src\/Application\/Http\/Handler\/LazyLoadingRequestHandler.php","line":35} [] []

Additional context
N/A.

Document cached config behavior

Is your feature request related to a problem? Please describe.

Current documentation does not remark the behavior of the cached config, this file is auto-generated in the first request if not exist, then it will be loaded from the filesystem instead of parsing again entire configs set.

This behavior generates confusion on development because if you add a new dependency via config the framework should no be able to load it until the cached config is regenerated.

To avoid this issue we use the development mode, this consist of avoiding to generate cached config file and regenerating every config on each request, to activate it the developer can use the dev-tool command bin/console config:development-mode or manually deleting cached config files and copying the config/services/*.dev.{php,yaml}.dist to the same path but without .dist` extension.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.